* @return true если можно, false если нет
*/
public boolean isEditable(@Nonnull PreparedTopic topic, @Nullable User by) {
Topic message = topic.getMessage();
Section section = topic.getSection();
User author = topic.getAuthor();
if (message.isDeleted()) {
return false;
}
if (by==null || by.isAnonymous() || by.isBlocked()) {
return false;
}
if (message.isExpired()) {
return false;
}
if (by.isAdministrator()) {
return true;
}
if (!topic.isLorcode()) {
return false;
}
if (by.isModerator()) {
return true;
}
if (by.canCorrect() && section.isPremoderated()) {
return true;
}
if (by.getId()==author.getId() && !message.isCommited()) {
if (message.isSticky()) {
return true;
}
if (section.isPremoderated()) {
return true;
}
if (message.isDraft()) {
return true;
}
if (author.getScore()>=EDIT_SELF_ALWAYS_SCORE) {
return !message.isExpired();
}
DateTime editDeadline = new DateTime(message.getPostdate()).plus(EDIT_PERIOD);