{"action":"created","issue":{"url":"https://api.github.com/repos/DoSomething/gladiator/issues/174","repository_url":"https://api.github.com/repos/DoSomething/gladiator","labels_url":"https://api.github.com/repos/DoSomething/gladiator/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/DoSomething/gladiator/issues/174/comments","events_url":"https://api.github.com/repos/DoSomething/gladiator/issues/174/events","html_url":"https://github.com/DoSomething/gladiator/pull/174","id":146082055,"number":174,"title":"Start sending to users","user":{"login":"sbsmith86","id":1700409,"avatar_url":"https://avatars.githubusercontent.com/u/1700409?v=3","gravatar_id":"","url":"https://api.github.com/users/sbsmith86","html_url":"https://github.com/sbsmith86","followers_url":"https://api.github.com/users/sbsmith86/followers","following_url":"https://api.github.com/users/sbsmith86/following{/other_user}","gists_url":"https://api.github.com/users/sbsmith86/gists{/gist_id}","starred_url":"https://api.github.com/users/sbsmith86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbsmith86/subscriptions","organizations_url":"https://api.github.com/users/sbsmith86/orgs","repos_url":"https://api.github.com/users/sbsmith86/repos","events_url":"https://api.github.com/users/sbsmith86/events{/privacy}","received_events_url":"https://api.github.com/users/sbsmith86/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"angaither","id":645205,"avatar_url":"https://avatars.githubusercontent.com/u/645205?v=3","gravatar_id":"","url":"https://api.github.com/users/angaither","html_url":"https://github.com/angaither","followers_url":"https://api.github.com/users/angaither/followers","following_url":"https://api.github.com/users/angaither/following{/other_user}","gists_url":"https://api.github.com/users/angaither/gists{/gist_id}","starred_url":"https://api.github.com/users/angaither/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angaither/subscriptions","organizations_url":"https://api.github.com/users/angaither/orgs","repos_url":"https://api.github.com/users/angaither/repos","events_url":"https://api.github.com/users/angaither/events{/privacy}","received_events_url":"https://api.github.com/users/angaither/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-04-05T19:09:25Z","updated_at":"2016-04-05T21:34:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/DoSomething/gladiator/pulls/174","html_url":"https://github.com/DoSomething/gladiator/pull/174","diff_url":"https://github.com/DoSomething/gladiator/pull/174.diff","patch_url":"https://github.com/DoSomething/gladiator/pull/174.patch"},"body":"#### What's this PR do?\r\n\r\nReworked this quite a bit...do you ever have one of those moments right before creating a PR where you are like...dafuq did I even do here :question: :exclamation: \r\n\r\nHere is how the logic flows from when the admin hits \"send\" to the user getting a message.\r\n\r\n* Admin hits \"send\"\r\n* A request is sent to the `sendMessage()` method in the `MessageController`\r\n  * This method is responsible for grabbing all the stuff that we need to build an `Email`, instantiating the email, and firing the event that will eventually handle the message sending.\r\n* An `Email` object gets built.\r\n  * This `Email` object contains everything we need to send a message to multiple users.\r\n     * It defines the tokens to look for and how to replace them\r\n     * It creates a custom message per user. I do this here because we might need to pass in user info to the subject, and the body of the email. So this way we get a processed message for each user and we can use that to send.\r\n     * the final object will look something like this:\r\n```\r\nEmail {\r\n contest -> Contest instance (the contest the message is for)\r\n allMessages -> [\r\n   0 => ['user' => Northstar User Object, 'message' => Processed Message  ]\r\n ]\r\n}\r\n```\r\n\r\n* the Message controller fires an event and passes the `Email` to it\r\n* The event is queued.\r\n* When the listener runs, it pulls in the `Email`, loops through each message and queues it to be sent. All of the configuration (from, to, etc) is done here.\r\n\r\n#### How should this be manually tested?\r\ntell us, how can we check that it works?\r\nPull down branch\r\n\r\n**VERY IMPORTANT** \r\nswitch your `MAIL_DRIVER` to `log` so you don't really send to anyone.\r\n\r\nrun the queue listener: `php artisan queue:listen`\r\n\r\nKick off a send. \r\ncheck your logs, you should see an email for each person in a competition, and tokens should be replaced.\r\n\r\n#### What are the relevant tickets?\r\nCloses #152 \r\n"},"comment":{"url":"https://api.github.com/repos/DoSomething/gladiator/issues/comments/205993207","html_url":"https://github.com/DoSomething/gladiator/pull/174#issuecomment-205993207","issue_url":"https://api.github.com/repos/DoSomething/gladiator/issues/174","id":205993207,"user":{"login":"sbsmith86","id":1700409,"avatar_url":"https://avatars.githubusercontent.com/u/1700409?v=3","gravatar_id":"","url":"https://api.github.com/users/sbsmith86","html_url":"https://github.com/sbsmith86","followers_url":"https://api.github.com/users/sbsmith86/followers","following_url":"https://api.github.com/users/sbsmith86/following{/other_user}","gists_url":"https://api.github.com/users/sbsmith86/gists{/gist_id}","starred_url":"https://api.github.com/users/sbsmith86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbsmith86/subscriptions","organizations_url":"https://api.github.com/users/sbsmith86/orgs","repos_url":"https://api.github.com/users/sbsmith86/repos","events_url":"https://api.github.com/users/sbsmith86/events{/privacy}","received_events_url":"https://api.github.com/users/sbsmith86/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T21:34:06Z","updated_at":"2016-04-05T21:34:06Z","body":"@angaither @DFurnes updated:\r\n\r\n* Pulling in UserRepository into the constructor and using it that way (`$this->userRepository`)\r\n* Checking for `APP_DEBUG` to determine who to send to, if it is dev mode, then is sends to the user who created the contest."}}