statusUpdateService.replyToStatus(escapedContent, status.getReplyTo(), attachmentIds);
} else if (status.isStatusPrivate() || status.getGroupId() == null || status.getGroupId().equals("")) {
log.debug("Private status");
statusUpdateService.postStatus(escapedContent, status.isStatusPrivate(), attachmentIds, status.getGeoLocalization());
} else {
User currentUser = authenticationService.getCurrentUser();
Collection<Group> groups = groupService.getGroupsForUser(currentUser);
Group group = null;
for (Group testGroup : groups) {
if (testGroup.getGroupId().equals(status.getGroupId())) {
group = testGroup;
break;
}
}
if (group == null) {
log.info("Permission denied! User {} tried to access " +
"group ID = {}", currentUser.getLogin(), status.getGroupId());
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
} else if (group.isArchivedGroup()) {
log.info("Archived group! User {} tried to post a message to archived " +
"group ID = {}", currentUser.getLogin(), status.getGroupId());
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
} else {
statusUpdateService.postStatusToGroup(escapedContent, group, attachmentIds, status.getGeoLocalization());
}
}