Search in sources :

Example 66 with User

use of org.mamute.model.User in project mamute by caelum.

the class NewQuestionMailer method send.

public void send(List<User> subscribed, Question question) {
    linker.linkTo(QuestionController.class).showQuestion(question, question.getSluggedTitle());
    String questionLink = linker.get();
    TemplateMail template = templates.template("new_question_notification").with("question", question).with("bundle", bundle).with("questionLink", questionLink).with("logoUrl", emailLogo);
    for (User user : subscribed) {
        boolean notSameAuthor = !user.equals(question.getAuthor());
        if (notSameAuthor) {
            Email email = template.to(user.getName(), user.getEmail());
            mailer.asyncSend(email);
        }
    }
}
Also used : QuestionController(org.mamute.controllers.QuestionController) User(org.mamute.model.User) Email(org.apache.commons.mail.Email) TemplateMail(br.com.caelum.vraptor.simplemail.template.TemplateMail)

Example 67 with User

use of org.mamute.model.User in project mamute by caelum.

the class NotificationMailer method send.

public void send(NotificationMail notificationMail) {
    User to = notificationMail.getTo();
    Email email = buildEmail(notificationMail);
    email.setCharset("utf-8");
    try {
        mailer.send(email);
    } catch (EmailException e) {
        LOG.error("Could not send notifications mail to: " + to.getEmail(), e);
    }
}
Also used : User(org.mamute.model.User) Email(org.apache.commons.mail.Email) EmailException(org.apache.commons.mail.EmailException)

Example 68 with User

use of org.mamute.model.User in project mamute by caelum.

the class SubscribeUsersToNewQuestion method subscribeUsers.

public void subscribeUsers(@Observes QuestionCreated questionCreated) {
    Question question = questionCreated.getQuestion();
    List<User> subscribed = users.findUsersSubscribedToAllQuestions();
    for (User user : subscribed) {
        watchers.add(question, new Watcher(user));
    }
    newQuestionMailer.send(subscribed, question);
}
Also used : User(org.mamute.model.User) Watcher(org.mamute.model.watch.Watcher) Question(org.mamute.model.Question)

Example 69 with User

use of org.mamute.model.User in project mamute by caelum.

the class TestCase method user.

protected User user(String name, String email) {
    User user = new User(SanitizedText.fromTrustedText(name), email);
    user.confirmEmail();
    return user;
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser)

Example 70 with User

use of org.mamute.model.User in project mamute by caelum.

the class UserDAOTest method should_find_by_session_key.

@Test
public void should_find_by_session_key() {
    User gui = user("Guilherme Sonar", "gui@email.com.br");
    users.save(gui);
    UserSession userSession = gui.newSession();
    users.save(userSession);
    assertEquals(gui, users.findBySessionKey(userSession.getSessionKey()).getUser());
    assertNull(users.findBySessionKey("12345"));
    assertNull(users.findBySessionKey(null));
}
Also used : User(org.mamute.model.User) UserSession(org.mamute.model.UserSession) Test(org.junit.Test)

Aggregations

User (org.mamute.model.User)97 Test (org.junit.Test)56 Question (org.mamute.model.Question)28 LoggedUser (org.mamute.model.LoggedUser)25 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)9 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)9 Answer (org.mamute.model.Answer)9 LoginMethod (org.mamute.model.LoginMethod)9 Post (br.com.caelum.vraptor.Post)7 Before (org.junit.Before)7 Tag (org.mamute.model.Tag)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Email (org.apache.commons.mail.Email)5 UserPersonalInfo (org.mamute.dto.UserPersonalInfo)5 ReputationEvent (org.mamute.model.ReputationEvent)5 ArrayList (java.util.ArrayList)4 Watcher (org.mamute.model.watch.Watcher)4 DateTime (org.joda.time.DateTime)3 Elements (org.jsoup.select.Elements)3 DaoManager (org.mamute.integration.util.DaoManager)3