MessageText text,
@Nullable Image image) {
try {
Group group = groupDao.getGroup(message.getGroupId());
User author = userDao.getUserCached(message.getUid());
Section section = sectionService.getSection(message.getSectionId());
DeleteInfo deleteInfo;
User deleteUser;
if (message.isDeleted()) {
deleteInfo = deleteInfoDao.getDeleteInfo(message.getId());
if (deleteInfo!=null) {
deleteUser = userDao.getUserCached(deleteInfo.getUserid());
} else {
deleteUser = null;
}
} else {
deleteInfo = null;
deleteUser = null;
}
PreparedPoll preparedPoll;
if (section.isPollPostAllowed()) {
if (poll==null) {
preparedPoll = pollPrepareService.preparePoll(message, user);
} else {
preparedPoll = poll;
}
} else {
preparedPoll = null;
}
User commiter;
if (message.getCommitby()!=0) {
commiter = userDao.getUserCached(message.getCommitby());
} else {
commiter = null;
}
EditInfoSummary editInfoSummary = editHistoryService.editInfoSummary(message.getId(), EditHistoryObjectTypeEnum.TOPIC);
User lastEditor;
int editCount;
Date lastEditDate;
if (editInfoSummary.editCount() > 0) {
BriefEditInfo editHistoryDto = editInfoSummary.lastEditInfo().get();
lastEditor = userDao.getUserCached(editHistoryDto.editor());
editCount = editInfoSummary.editCount();
lastEditDate = editHistoryDto.editdate();
} else {
lastEditDate = null;
lastEditor = null;
editCount = 0;
}
String processedMessage;
if (text.isLorcode()) {
if (minimizeCut) {
String url = siteConfig.getMainUrl() + message.getLink();
processedMessage = lorCodeService.parseTopicWithMinimizedCut(
text.getText(),
url,
secure,
! topicPermissionService.followInTopic(message, author)
);
} else {
processedMessage = lorCodeService.parseTopic(text.getText(), secure, ! topicPermissionService.followInTopic(message, author));
}
} else {
processedMessage = "<p>" + text.getText();
}
PreparedImage preparedImage = null;
if (section.isImagepost() || section.isImageAllowed()) {
if (message.getId()!=0) {
image = imageDao.imageForTopic(message);
}
if (image != null) {