{"action":"created","comment":{"url":"https://api.github.com/repos/vampaynani/TATickets/pulls/comments/181456841","pull_request_review_id":112094441,"id":181456841,"diff_hunk":"@@ -1,78 +1,96 @@\n const express = require('express');\n-const moment = require('moment');\n+const moment = require('moment-timezone');\n const axios = require('axios');\n \n const router = express.Router();\n \n-const { Ticket } = require('../../models');\n+const { Mentor, Ticket } = require('../../models');\n+const { formatTicketMessage } = require('../../helpers')\n \n router.post('/', (req, res, next) => {\n   const {channel_id, user_name, response_url, text} = req.body;\n   const today = moment().startOf('day');\n   const tomorrow = moment(today).add(1, 'days');\n-  const sentences = text ? text.split(' ') : [];\n+  const sentences = text\n+    ? text.split(' ')\n+    : [];\n   let session = sentences.find(sentence => sentence.includes('http://') || sentence.includes('https://'));\n   let issue = sentences.filter(sentence => sentence !== session).join(' ');\n-  if(text === \"cancel\" || text === \"remove\"){\n+  if (text === \"cancel\" || text === \"remove\") {\n     Ticket.findOne({\n       by: user_name,\n       channelId: channel_id,\n       mentor: null,\n       isActive: true,\n-      attended_at: { $exists: false }\n-    })\n-    .then(ticket => {\n-      if(ticket){\n+      attended_at: {\n+        $exists: false\n+      }\n+    }).then(ticket => {\n+      if (ticket) {\n         ticket.remove();\n-        res.status(200).json({\n-          response_type: \"ephemeral\",\n-          text: `Request successfully removed from the queue`\n-        });\n+        res.status(200).json({response_type: \"ephemeral\", text: `Request successfully removed from the queue`});\n         axios.post(response_url, {\n           response_type: \"in_channel\",\n           text: `${ticket.owlSession} removed from the queue`\n         });\n-      }else{\n+      } else {\n         next(`No ticket available to cancel`);\n       }\n     });\n     return;\n   }\n-  if(!session) {\n+  \n+  const hours = moment().get('hour');\n+  const minutes = moment().get('minutes')\n+  // Morning start time, 11AM Eastern\n+  if (hours < 11)\n+    throw 'Oops! TA support is available starting at 11AM Eastern, please request again later!';\n+\n+  // Lunch between 12:45 and 1:30 Eastern\n+  if ((hours === 12 && minutes >= 45) || (hours === 13 && minutes <= 30))\n+    throw \"Oops! It's lunch time, TAs will be back at 1:30 Eastern\";\n+\n+  // Afternoon TA end time, 5:30 Eastern\n+  if ((hours === 17 && minutes > 30) || hours >= 18)\n+    throw 'Oops! TA support is only available until 4:30 Eastern!';\n+\n+  if (!session) {\n     //return next(`You need to type a valid session url to be able to push it to the queue`);\n     session = `https://sessions.thinkful.com/${user_name}`\n   }\n   Ticket.findOne({\n     owlSession: session,\n     channelId: channel_id,\n     mentor: null,\n-    created_at: { $gte: today.toDate() }\n-  })\n-  .then(ticket => {\n-    if(ticket){\n+    created_at: {\n+      $gte: today.toDate()\n+    }\n+  }).then(ticket => {\n+    if (ticket) {\n       return Promise.reject(`The session url has been already pushed to the queue, a mentor will reach you out soon`);\n-    }else{\n-      return Ticket.create({\n-        issue,\n-        owlSession: session,\n-        by: user_name,\n-        channelId: channel_id\n-      });\n+    } else {\n+      return Ticket.create({issue, owlSession: session, by: user_name, channelId: channel_id});\n     }\n-  })\n-  .then(ticket => {\n-    const postIssue = issue ? `issued: ${issue[issue.length - 1] === \".\" ? issue : `${issue}.`} In ${session}` : `required a mentor in ${session}`;\n+  }).then(mentors => {","path":"routes/commands/support.js","position":104,"original_position":102,"commit_id":"d3c348293390b90aa96b9bc98850a6719af8ec61","original_commit_id":"d50c39c604df733a6e2eaa7d181b5ac8272489b4","user":{"login":"vampaynani","id":350815,"avatar_url":"https://avatars1.githubusercontent.com/u/350815?v=4","gravatar_id":"","url":"https://api.github.com/users/vampaynani","html_url":"https://github.com/vampaynani","followers_url":"https://api.github.com/users/vampaynani/followers","following_url":"https://api.github.com/users/vampaynani/following{/other_user}","gists_url":"https://api.github.com/users/vampaynani/gists{/gist_id}","starred_url":"https://api.github.com/users/vampaynani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vampaynani/subscriptions","organizations_url":"https://api.github.com/users/vampaynani/orgs","repos_url":"https://api.github.com/users/vampaynani/repos","events_url":"https://api.github.com/users/vampaynani/events{/privacy}","received_events_url":"https://api.github.com/users/vampaynani/received_events","type":"User","site_admin":false},"body":"Don't this param will be still ticket instead of mentors?","created_at":"2018-04-13T17:25:49Z","updated_at":"2018-04-13T17:25:50Z","html_url":"https://github.com/vampaynani/TATickets/pull/5#discussion_r181456841","pull_request_url":"https://api.github.com/repos/vampaynani/TATickets/pulls/5","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/vampaynani/TATickets/pulls/comments/181456841"},"html":{"href":"https://github.com/vampaynani/TATickets/pull/5#discussion_r181456841"},"pull_request":{"href":"https://api.github.com/repos/vampaynani/TATickets/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/vampaynani/TATickets/pulls/5","id":181535079,"html_url":"https://github.com/vampaynani/TATickets/pull/5","diff_url":"https://github.com/vampaynani/TATickets/pull/5.diff","patch_url":"https://github.com/vampaynani/TATickets/pull/5.patch","issue_url":"https://api.github.com/repos/vampaynani/TATickets/issues/5","number":5,"state":"open","locked":false,"title":"Add custom notifications and restrict requests to the correct times","user":{"login":"bookcasey","id":1432129,"avatar_url":"https://avatars3.githubusercontent.com/u/1432129?v=4","gravatar_id":"","url":"https://api.github.com/users/bookcasey","html_url":"https://github.com/bookcasey","followers_url":"https://api.github.com/users/bookcasey/followers","following_url":"https://api.github.com/users/bookcasey/following{/other_user}","gists_url":"https://api.github.com/users/bookcasey/gists{/gist_id}","starred_url":"https://api.github.com/users/bookcasey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bookcasey/subscriptions","organizations_url":"https://api.github.com/users/bookcasey/orgs","repos_url":"https://api.github.com/users/bookcasey/repos","events_url":"https://api.github.com/users/bookcasey/events{/privacy}","received_events_url":"https://api.github.com/users/bookcasey/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-13T16:19:44Z","updated_at":"2018-04-13T17:25:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b5b5cc4139323d241a01a7c5553ee14709848756","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/vampaynani/TATickets/pulls/5/commits","review_comments_url":"https://api.github.com/repos/vampaynani/TATickets/pulls/5/comments","review_comment_url":"https://api.github.com/repos/vampaynani/TATickets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vampaynani/TATickets/issues/5/comments","statuses_url":"https://api.github.com/repos/vampaynani/TATickets/statuses/d3c348293390b90aa96b9bc98850a6719af8ec61","head":{"label":"bookcasey:master","ref":"master","sha":"d3c348293390b90aa96b9bc98850a6719af8ec61","user":{"login":"bookcasey","id":1432129,"avatar_url":"https://avatars3.githubusercontent.com/u/1432129?v=4","gravatar_id":"","url":"https://api.github.com/users/bookcasey","html_url":"https://github.com/bookcasey","followers_url":"https://api.github.com/users/bookcasey/followers","following_url":"https://api.github.com/users/bookcasey/following{/other_user}","gists_url":"https://api.github.com/users/bookcasey/gists{/gist_id}","starred_url":"https://api.github.com/users/bookcasey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bookcasey/subscriptions","organizations_url":"https://api.github.com/users/bookcasey/orgs","repos_url":"https://api.github.com/users/bookcasey/repos","events_url":"https://api.github.com/users/bookcasey/events{/privacy}","received_events_url":"https://api.github.com/users/bookcasey/received_events","type":"User","site_admin":false},"repo":{"id":129110765,"name":"TATickets","full_name":"bookcasey/TATickets","owner":{"login":"bookcasey","id":1432129,"avatar_url":"https://avatars3.githubusercontent.com/u/1432129?v=4","gravatar_id":"","url":"https://api.github.com/users/bookcasey","html_url":"https://github.com/bookcasey","followers_url":"https://api.github.com/users/bookcasey/followers","following_url":"https://api.github.com/users/bookcasey/following{/other_user}","gists_url":"https://api.github.com/users/bookcasey/gists{/gist_id}","starred_url":"https://api.github.com/users/bookcasey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bookcasey/subscriptions","organizations_url":"https://api.github.com/users/bookcasey/orgs","repos_url":"https://api.github.com/users/bookcasey/repos","events_url":"https://api.github.com/users/bookcasey/events{/privacy}","received_events_url":"https://api.github.com/users/bookcasey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bookcasey/TATickets","description":null,"fork":true,"url":"https://api.github.com/repos/bookcasey/TATickets","forks_url":"https://api.github.com/repos/bookcasey/TATickets/forks","keys_url":"https://api.github.com/repos/bookcasey/TATickets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bookcasey/TATickets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bookcasey/TATickets/teams","hooks_url":"https://api.github.com/repos/bookcasey/TATickets/hooks","issue_events_url":"https://api.github.com/repos/bookcasey/TATickets/issues/events{/number}","events_url":"https://api.github.com/repos/bookcasey/TATickets/events","assignees_url":"https://api.github.com/repos/bookcasey/TATickets/assignees{/user}","branches_url":"https://api.github.com/repos/bookcasey/TATickets/branches{/branch}","tags_url":"https://api.github.com/repos/bookcasey/TATickets/tags","blobs_url":"https://api.github.com/repos/bookcasey/TATickets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bookcasey/TATickets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bookcasey/TATickets/git/refs{/sha}","trees_url":"https://api.github.com/repos/bookcasey/TATickets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bookcasey/TATickets/statuses/{sha}","languages_url":"https://api.github.com/repos/bookcasey/TATickets/languages","stargazers_url":"https://api.github.com/repos/bookcasey/TATickets/stargazers","contributors_url":"https://api.github.com/repos/bookcasey/TATickets/contributors","subscribers_url":"https://api.github.com/repos/bookcasey/TATickets/subscribers","subscription_url":"https://api.github.com/repos/bookcasey/TATickets/subscription","commits_url":"https://api.github.com/repos/bookcasey/TATickets/commits{/sha}","git_commits_url":"https://api.github.com/repos/bookcasey/TATickets/git/commits{/sha}","comments_url":"https://api.github.com/repos/bookcasey/TATickets/comments{/number}","issue_comment_url":"https://api.github.com/repos/bookcasey/TATickets/issues/comments{/number}","contents_url":"https://api.github.com/repos/bookcasey/TATickets/contents/{+path}","compare_url":"https://api.github.com/repos/bookcasey/TATickets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bookcasey/TATickets/merges","archive_url":"https://api.github.com/repos/bookcasey/TATickets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bookcasey/TATickets/downloads","issues_url":"https://api.github.com/repos/bookcasey/TATickets/issues{/number}","pulls_url":"https://api.github.com/repos/bookcasey/TATickets/pulls{/number}","milestones_url":"https://api.github.com/repos/bookcasey/TATickets/milestones{/number}","notifications_url":"https://api.github.com/repos/bookcasey/TATickets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bookcasey/TATickets/labels{/name}","releases_url":"https://api.github.com/repos/bookcasey/TATickets/releases{/id}","deployments_url":"https://api.github.com/repos/bookcasey/TATickets/deployments","created_at":"2018-04-11T14:57:28Z","updated_at":"2018-04-13T16:12:34Z","pushed_at":"2018-04-13T16:48:44Z","git_url":"git://github.com/bookcasey/TATickets.git","ssh_url":"git@github.com:bookcasey/TATickets.git","clone_url":"https://github.com/bookcasey/TATickets.git","svn_url":"https://github.com/bookcasey/TATickets","homepage":null,"size":99,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vampaynani:master","ref":"master","sha":"ec2c57dd6d24ecf087206f1bf09e6110f9a3da5d","user":{"login":"vampaynani","id":350815,"avatar_url":"https://avatars1.githubusercontent.com/u/350815?v=4","gravatar_id":"","url":"https://api.github.com/users/vampaynani","html_url":"https://github.com/vampaynani","followers_url":"https://api.github.com/users/vampaynani/followers","following_url":"https://api.github.com/users/vampaynani/following{/other_user}","gists_url":"https://api.github.com/users/vampaynani/gists{/gist_id}","starred_url":"https://api.github.com/users/vampaynani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vampaynani/subscriptions","organizations_url":"https://api.github.com/users/vampaynani/orgs","repos_url":"https://api.github.com/users/vampaynani/repos","events_url":"https://api.github.com/users/vampaynani/events{/privacy}","received_events_url":"https://api.github.com/users/vampaynani/received_events","type":"User","site_admin":false},"repo":{"id":124586762,"name":"TATickets","full_name":"vampaynani/TATickets","owner":{"login":"vampaynani","id":350815,"avatar_url":"https://avatars1.githubusercontent.com/u/350815?v=4","gravatar_id":"","url":"https://api.github.com/users/vampaynani","html_url":"https://github.com/vampaynani","followers_url":"https://api.github.com/users/vampaynani/followers","following_url":"https://api.github.com/users/vampaynani/following{/other_user}","gists_url":"https://api.github.com/users/vampaynani/gists{/gist_id}","starred_url":"https://api.github.com/users/vampaynani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vampaynani/subscriptions","organizations_url":"https://api.github.com/users/vampaynani/orgs","repos_url":"https://api.github.com/users/vampaynani/repos","events_url":"https://api.github.com/users/vampaynani/events{/privacy}","received_events_url":"https://api.github.com/users/vampaynani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vampaynani/TATickets","description":null,"fork":false,"url":"https://api.github.com/repos/vampaynani/TATickets","forks_url":"https://api.github.com/repos/vampaynani/TATickets/forks","keys_url":"https://api.github.com/repos/vampaynani/TATickets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vampaynani/TATickets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vampaynani/TATickets/teams","hooks_url":"https://api.github.com/repos/vampaynani/TATickets/hooks","issue_events_url":"https://api.github.com/repos/vampaynani/TATickets/issues/events{/number}","events_url":"https://api.github.com/repos/vampaynani/TATickets/events","assignees_url":"https://api.github.com/repos/vampaynani/TATickets/assignees{/user}","branches_url":"https://api.github.com/repos/vampaynani/TATickets/branches{/branch}","tags_url":"https://api.github.com/repos/vampaynani/TATickets/tags","blobs_url":"https://api.github.com/repos/vampaynani/TATickets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vampaynani/TATickets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vampaynani/TATickets/git/refs{/sha}","trees_url":"https://api.github.com/repos/vampaynani/TATickets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vampaynani/TATickets/statuses/{sha}","languages_url":"https://api.github.com/repos/vampaynani/TATickets/languages","stargazers_url":"https://api.github.com/repos/vampaynani/TATickets/stargazers","contributors_url":"https://api.github.com/repos/vampaynani/TATickets/contributors","subscribers_url":"https://api.github.com/repos/vampaynani/TATickets/subscribers","subscription_url":"https://api.github.com/repos/vampaynani/TATickets/subscription","commits_url":"https://api.github.com/repos/vampaynani/TATickets/commits{/sha}","git_commits_url":"https://api.github.com/repos/vampaynani/TATickets/git/commits{/sha}","comments_url":"https://api.github.com/repos/vampaynani/TATickets/comments{/number}","issue_comment_url":"https://api.github.com/repos/vampaynani/TATickets/issues/comments{/number}","contents_url":"https://api.github.com/repos/vampaynani/TATickets/contents/{+path}","compare_url":"https://api.github.com/repos/vampaynani/TATickets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vampaynani/TATickets/merges","archive_url":"https://api.github.com/repos/vampaynani/TATickets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vampaynani/TATickets/downloads","issues_url":"https://api.github.com/repos/vampaynani/TATickets/issues{/number}","pulls_url":"https://api.github.com/repos/vampaynani/TATickets/pulls{/number}","milestones_url":"https://api.github.com/repos/vampaynani/TATickets/milestones{/number}","notifications_url":"https://api.github.com/repos/vampaynani/TATickets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vampaynani/TATickets/labels{/name}","releases_url":"https://api.github.com/repos/vampaynani/TATickets/releases{/id}","deployments_url":"https://api.github.com/repos/vampaynani/TATickets/deployments","created_at":"2018-03-09T19:54:47Z","updated_at":"2018-04-13T14:36:34Z","pushed_at":"2018-04-13T16:19:45Z","git_url":"git://github.com/vampaynani/TATickets.git","ssh_url":"git@github.com:vampaynani/TATickets.git","clone_url":"https://github.com/vampaynani/TATickets.git","svn_url":"https://github.com/vampaynani/TATickets","homepage":null,"size":85,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vampaynani/TATickets/pulls/5"},"html":{"href":"https://github.com/vampaynani/TATickets/pull/5"},"issue":{"href":"https://api.github.com/repos/vampaynani/TATickets/issues/5"},"comments":{"href":"https://api.github.com/repos/vampaynani/TATickets/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/vampaynani/TATickets/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/vampaynani/TATickets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vampaynani/TATickets/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/vampaynani/TATickets/statuses/d3c348293390b90aa96b9bc98850a6719af8ec61"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"vampaynani"}}