{"action":"created","comment":{"url":"https://api.github.com/repos/thorncp/ReviewSite/pulls/comments/22543968","id":22543968,"diff_hunk":"@@ -1,61 +1,69 @@\n- class Invitation < ActiveRecord::Base\n-  belongs_to :review\n-  attr_accessible :email, :username\n-\n-  VALID_EMAIL_REGEX = /\\A[\\w+\\-.]+@[a-z\\d\\-.]+\\.[a-z]+\\z/i\n-  validates :email, presence: { message: \"Email cannot be blank.\" },\n-                    format: {\n-                      with: VALID_EMAIL_REGEX,\n-                      message: \"%{value} could not be invited -- Invalid Email.\" },\n-                    uniqueness: {\n-                      case_sensitive: false,\n-                      scope: [:review_id],\n-                      message: \"%{value} could not be invited -- Email already invited.\" }\n-  validate :has_no_feedback?\n-  validate :tw_email?\n-\n-  def tw_email?\n-    if email && !errors[:email].any? && !email.include?(\"@thoughtworks.com\")\n-      errors.add(:email,\"#{email} could not be invited -- Not a ThoughtWorks Email.\")\n-    end\n-  end\n-\n-  def has_no_feedback?\n-    if feedback\n-      errors.clear\n-      errors.add(:review, \"#{user.email} has already given feedback for this review.\")\n-    end\n-  end\n-\n-  def sent_date\n-    created_at.to_date\n-  end\n-\n-  def user\n-    User.find_by_email(email)\n-  end\n-\n-  def feedback\n-    review.feedbacks.includes(:user).each do |f|\n-      return f if f.user == user\n-    end\n-    nil\n-  end\n-\n-  def delete_invite\n-      review.invitations.delete(self)\n-  end\n-\n-  def sent_to?(user)\n-    return false if user.nil?\n-    user == self.user\n-  end\n-\n-  def reviewee\n-    review.associate_consultant\n-  end\n-\n-  def expired?\n-    review.feedback_deadline < Date.today and feedback and feedback.submitted?\n-  end\n-end\n+ class Invitation < ActiveRecord::Base\r\n+  belongs_to :review\r\n+  attr_accessible :email, :username\r\n+\r\n+  VALID_EMAIL_REGEX = /\\A[\\w+\\-.]+@[a-z\\d\\-.]+\\.[a-z]+\\z/i\r\n+  validates :email, presence: { message: \"Email cannot be blank.\" },\r\n+                    format: {\r\n+                      with: VALID_EMAIL_REGEX,\r\n+                      message: \"%{value} could not be invited -- Invalid Email.\" },\r\n+                    uniqueness: {\r\n+                      case_sensitive: false,\r\n+                      scope: [:review_id],\r\n+                      message: \"%{value} could not be invited -- Email already invited.\" }\r\n+  validate :has_no_feedback?\r\n+  validate :tw_email?\r\n+\r\n+  def tw_email?\r\n+    if email && !errors[:email].any? && !email.include?(\"@thoughtworks.com\")\r\n+      errors.add(:email,\"#{email} could not be invited -- Not a ThoughtWorks Email.\")\r\n+    end\r\n+  end\r\n+\r\n+  def has_no_feedback?\r\n+    if feedback\r\n+      errors.clear\r\n+      errors.add(:review, \"#{user.email} has already given feedback for this review.\")\r\n+    end\r\n+  end\r\n+\r\n+  def sent_date\r\n+    created_at.to_date\r\n+  end\r\n+\r\n+  def user\r\n+    user = User.find_by_email(email)\r\n+    if !user.nil?\r\n+      user\r\n+    else\r\n+     email = AdditionalEmail.find_by_email(email)\r\n+     if !email.nil? && email.confirmed_at?\r\n+       User.find(email.user_id)\r\n+     end\r\n+   end\r\n+  end\r\n+\r\n+  def feedback\r\n+    review.feedbacks.includes(:user).each do |f|\r\n+      return f if f.user == user\r\n+    end\r\n+    nil\r\n+  end\r\n+\r\n+  def delete_invite\r\n+      review.invitations.delete(self)\r\n+  end\r\n+\r\n+  def sent_to?(user)\r\n+    return false if user.nil?\r\n+    user == self.user\r\n+  end\r\n+\r\n+  def reviewee\r\n+    review.associate_consultant\r\n+  end\r\n+\r\n+  def expired?\r\n+    review.feedback_deadline < Date.today and feedback and feedback.submitted?\r","path":"app/models/invitation.rb","position":128,"original_position":128,"commit_id":"de255ff8967687e0b5041dc5b839349295d1597d","original_commit_id":"de255ff8967687e0b5041dc5b839349295d1597d","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Use `&&` instead of `and`.","created_at":"2015-01-06T19:14:35Z","updated_at":"2015-01-06T19:14:35Z","html_url":"https://github.com/thorncp/ReviewSite/pull/20#discussion_r22543968","pull_request_url":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/thorncp/ReviewSite/pulls/comments/22543968"},"html":{"href":"https://github.com/thorncp/ReviewSite/pull/20#discussion_r22543968"},"pull_request":{"href":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20","id":26910249,"html_url":"https://github.com/thorncp/ReviewSite/pull/20","diff_url":"https://github.com/thorncp/ReviewSite/pull/20.diff","patch_url":"https://github.com/thorncp/ReviewSite/pull/20.patch","issue_url":"https://api.github.com/repos/thorncp/ReviewSite/issues/20","number":20,"state":"open","locked":false,"title":"Another branch","user":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-06T19:10:24Z","updated_at":"2015-01-06T19:14:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2aa911d5ab2bd76e97cff6b5f4f752347852b8ff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20/commits","review_comments_url":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20/comments","review_comment_url":"https://api.github.com/repos/thorncp/ReviewSite/pulls/comments/{number}","comments_url":"https://api.github.com/repos/thorncp/ReviewSite/issues/20/comments","statuses_url":"https://api.github.com/repos/thorncp/ReviewSite/statuses/de255ff8967687e0b5041dc5b839349295d1597d","head":{"label":"thorncp:another-branch","ref":"another-branch","sha":"de255ff8967687e0b5041dc5b839349295d1597d","user":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"repo":{"id":28833458,"name":"ReviewSite","full_name":"thorncp/ReviewSite","owner":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thorncp/ReviewSite","description":"","fork":false,"url":"https://api.github.com/repos/thorncp/ReviewSite","forks_url":"https://api.github.com/repos/thorncp/ReviewSite/forks","keys_url":"https://api.github.com/repos/thorncp/ReviewSite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thorncp/ReviewSite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thorncp/ReviewSite/teams","hooks_url":"https://api.github.com/repos/thorncp/ReviewSite/hooks","issue_events_url":"https://api.github.com/repos/thorncp/ReviewSite/issues/events{/number}","events_url":"https://api.github.com/repos/thorncp/ReviewSite/events","assignees_url":"https://api.github.com/repos/thorncp/ReviewSite/assignees{/user}","branches_url":"https://api.github.com/repos/thorncp/ReviewSite/branches{/branch}","tags_url":"https://api.github.com/repos/thorncp/ReviewSite/tags","blobs_url":"https://api.github.com/repos/thorncp/ReviewSite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thorncp/ReviewSite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thorncp/ReviewSite/git/refs{/sha}","trees_url":"https://api.github.com/repos/thorncp/ReviewSite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thorncp/ReviewSite/statuses/{sha}","languages_url":"https://api.github.com/repos/thorncp/ReviewSite/languages","stargazers_url":"https://api.github.com/repos/thorncp/ReviewSite/stargazers","contributors_url":"https://api.github.com/repos/thorncp/ReviewSite/contributors","subscribers_url":"https://api.github.com/repos/thorncp/ReviewSite/subscribers","subscription_url":"https://api.github.com/repos/thorncp/ReviewSite/subscription","commits_url":"https://api.github.com/repos/thorncp/ReviewSite/commits{/sha}","git_commits_url":"https://api.github.com/repos/thorncp/ReviewSite/git/commits{/sha}","comments_url":"https://api.github.com/repos/thorncp/ReviewSite/comments{/number}","issue_comment_url":"https://api.github.com/repos/thorncp/ReviewSite/issues/comments/{number}","contents_url":"https://api.github.com/repos/thorncp/ReviewSite/contents/{+path}","compare_url":"https://api.github.com/repos/thorncp/ReviewSite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thorncp/ReviewSite/merges","archive_url":"https://api.github.com/repos/thorncp/ReviewSite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thorncp/ReviewSite/downloads","issues_url":"https://api.github.com/repos/thorncp/ReviewSite/issues{/number}","pulls_url":"https://api.github.com/repos/thorncp/ReviewSite/pulls{/number}","milestones_url":"https://api.github.com/repos/thorncp/ReviewSite/milestones{/number}","notifications_url":"https://api.github.com/repos/thorncp/ReviewSite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thorncp/ReviewSite/labels{/name}","releases_url":"https://api.github.com/repos/thorncp/ReviewSite/releases{/id}","created_at":"2015-01-05T21:49:16Z","updated_at":"2015-01-05T21:49:26Z","pushed_at":"2015-01-06T19:13:45Z","git_url":"git://github.com/thorncp/ReviewSite.git","ssh_url":"git@github.com:thorncp/ReviewSite.git","clone_url":"https://github.com/thorncp/ReviewSite.git","svn_url":"https://github.com/thorncp/ReviewSite","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"thorncp:master","ref":"master","sha":"ef64c6a86e31a676b14dbeae89d101074307898d","user":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"repo":{"id":28833458,"name":"ReviewSite","full_name":"thorncp/ReviewSite","owner":{"login":"thorncp","id":72176,"avatar_url":"https://avatars.githubusercontent.com/u/72176?v=3","gravatar_id":"","url":"https://api.github.com/users/thorncp","html_url":"https://github.com/thorncp","followers_url":"https://api.github.com/users/thorncp/followers","following_url":"https://api.github.com/users/thorncp/following{/other_user}","gists_url":"https://api.github.com/users/thorncp/gists{/gist_id}","starred_url":"https://api.github.com/users/thorncp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorncp/subscriptions","organizations_url":"https://api.github.com/users/thorncp/orgs","repos_url":"https://api.github.com/users/thorncp/repos","events_url":"https://api.github.com/users/thorncp/events{/privacy}","received_events_url":"https://api.github.com/users/thorncp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thorncp/ReviewSite","description":"","fork":false,"url":"https://api.github.com/repos/thorncp/ReviewSite","forks_url":"https://api.github.com/repos/thorncp/ReviewSite/forks","keys_url":"https://api.github.com/repos/thorncp/ReviewSite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thorncp/ReviewSite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thorncp/ReviewSite/teams","hooks_url":"https://api.github.com/repos/thorncp/ReviewSite/hooks","issue_events_url":"https://api.github.com/repos/thorncp/ReviewSite/issues/events{/number}","events_url":"https://api.github.com/repos/thorncp/ReviewSite/events","assignees_url":"https://api.github.com/repos/thorncp/ReviewSite/assignees{/user}","branches_url":"https://api.github.com/repos/thorncp/ReviewSite/branches{/branch}","tags_url":"https://api.github.com/repos/thorncp/ReviewSite/tags","blobs_url":"https://api.github.com/repos/thorncp/ReviewSite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thorncp/ReviewSite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thorncp/ReviewSite/git/refs{/sha}","trees_url":"https://api.github.com/repos/thorncp/ReviewSite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thorncp/ReviewSite/statuses/{sha}","languages_url":"https://api.github.com/repos/thorncp/ReviewSite/languages","stargazers_url":"https://api.github.com/repos/thorncp/ReviewSite/stargazers","contributors_url":"https://api.github.com/repos/thorncp/ReviewSite/contributors","subscribers_url":"https://api.github.com/repos/thorncp/ReviewSite/subscribers","subscription_url":"https://api.github.com/repos/thorncp/ReviewSite/subscription","commits_url":"https://api.github.com/repos/thorncp/ReviewSite/commits{/sha}","git_commits_url":"https://api.github.com/repos/thorncp/ReviewSite/git/commits{/sha}","comments_url":"https://api.github.com/repos/thorncp/ReviewSite/comments{/number}","issue_comment_url":"https://api.github.com/repos/thorncp/ReviewSite/issues/comments/{number}","contents_url":"https://api.github.com/repos/thorncp/ReviewSite/contents/{+path}","compare_url":"https://api.github.com/repos/thorncp/ReviewSite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thorncp/ReviewSite/merges","archive_url":"https://api.github.com/repos/thorncp/ReviewSite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thorncp/ReviewSite/downloads","issues_url":"https://api.github.com/repos/thorncp/ReviewSite/issues{/number}","pulls_url":"https://api.github.com/repos/thorncp/ReviewSite/pulls{/number}","milestones_url":"https://api.github.com/repos/thorncp/ReviewSite/milestones{/number}","notifications_url":"https://api.github.com/repos/thorncp/ReviewSite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thorncp/ReviewSite/labels{/name}","releases_url":"https://api.github.com/repos/thorncp/ReviewSite/releases{/id}","created_at":"2015-01-05T21:49:16Z","updated_at":"2015-01-05T21:49:26Z","pushed_at":"2015-01-06T19:13:45Z","git_url":"git://github.com/thorncp/ReviewSite.git","ssh_url":"git@github.com:thorncp/ReviewSite.git","clone_url":"https://github.com/thorncp/ReviewSite.git","svn_url":"https://github.com/thorncp/ReviewSite","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20"},"html":{"href":"https://github.com/thorncp/ReviewSite/pull/20"},"issue":{"href":"https://api.github.com/repos/thorncp/ReviewSite/issues/20"},"comments":{"href":"https://api.github.com/repos/thorncp/ReviewSite/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/thorncp/ReviewSite/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/thorncp/ReviewSite/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/thorncp/ReviewSite/statuses/de255ff8967687e0b5041dc5b839349295d1597d"}}}}