session.get().save(groupMembership);
tx.commit();
return groupMembership;
} else if (!group.isAutoJoin()) {
tx = session.get().beginTransaction();
PendingGroupMembership groupMembership = new PendingGroupMembership();
groupMembership.setUser(user);
groupMembership.setUserGroup(group);
session.get().save(groupMembership);
tx.commit();
// send email to group owner
BaseSystem.getEmailService().sendMessage(BaseSystem.getSmtpHost(), BaseSystem.getAdminEmailAddress(), BaseSystem.getAdminEmailAddress(),
group.getOwner().getEmail(), "Group join request from " + user.getUsername(),