Search in sources :

Example 1 with UserContactDao

use of org.apache.openmeetings.db.dao.user.UserContactDao in project openmeetings by apache.

the class ContactsHelper method acceptUserContact.

public static Object acceptUserContact(long userContactId) {
    UserContactDao dao = get().getBean(UserContactDao.class);
    UserContact contact = dao.get(userContactId);
    if (contact == null) {
        return "error.contact.denied";
    }
    if (!contact.isPending()) {
        return "error.contact.approved";
    }
    dao.updateContactStatus(userContactId, false);
    contact = dao.get(userContactId);
    User user = contact.getOwner();
    dao.add(user.getId(), getUserId(), false);
    if (user.getAddress() != null) {
        String message = RequestContactConfirmTemplate.getEmail(contact);
        String subj = contact.getContact().getFirstname() + " " + contact.getContact().getLastname() + " " + Application.getString("1198");
        get().getBean(PrivateMessageDao.class).addPrivateMessage(subj, message, contact.getContact(), user, user, false, 0L);
        get().getBean(MailHandler.class).send(user.getAddress().getEmail(), subj, message);
    }
    return userContactId;
}
Also used : MailHandler(org.apache.openmeetings.core.mail.MailHandler) User(org.apache.openmeetings.db.entity.user.User) PrivateMessageDao(org.apache.openmeetings.db.dao.user.PrivateMessageDao) UserContact(org.apache.openmeetings.db.entity.user.UserContact) UserContactDao(org.apache.openmeetings.db.dao.user.UserContactDao)

Aggregations

MailHandler (org.apache.openmeetings.core.mail.MailHandler)1 PrivateMessageDao (org.apache.openmeetings.db.dao.user.PrivateMessageDao)1 UserContactDao (org.apache.openmeetings.db.dao.user.UserContactDao)1 User (org.apache.openmeetings.db.entity.user.User)1 UserContact (org.apache.openmeetings.db.entity.user.UserContact)1