{"action":"created","comment":{"url":"https://api.github.com/repos/evercam/evercam-media/pulls/comments/67707989","id":67707989,"diff_hunk":"@@ -33,11 +38,47 @@ defmodule CameraShareRequest do\n     |> Repo.all\n   end\n \n+  def get_pending_request(camera, email) do\n+    CameraShareRequest\n+    |> where(camera_id: ^camera.id)\n+    |> where(status: ^@status.pending)\n+    |> where(email: ^email)\n+    |> Repo.one\n+  end\n+\n   def get_status(status) do\n     case status do\n       \"used\" -> @status.used\n       \"cancelled\" -> @status.cancelled\n       \"pending\" -> @status.pending\n     end\n   end\n+\n+  def create_share_request(camera, email, sharer, rights, message) do\n+    share_request_params = %{\n+        camera_id: camera.id,\n+        user_id: sharer.id,\n+        status: status.pending,\n+        email: email,\n+        rights: rights,\n+        message: message,\n+        key: UUID.uuid4(:hex)\n+      }\n+    changeset = changeset(%CameraShareRequest{}, share_request_params)\n+    case Repo.insert(changeset) do\n+      {:ok, share_request} ->\n+        camera_share_request =\n+          share_request\n+            |> Repo.preload(:camera)","path":"web/models/camera_share_request.ex","position":57,"original_position":57,"commit_id":"020756fb5e135aaa0f5af7b5a70dcf9f03facc36","original_commit_id":"020756fb5e135aaa0f5af7b5a70dcf9f03facc36","user":{"login":"mosic","id":1229422,"avatar_url":"https://avatars.githubusercontent.com/u/1229422?v=3","gravatar_id":"","url":"https://api.github.com/users/mosic","html_url":"https://github.com/mosic","followers_url":"https://api.github.com/users/mosic/followers","following_url":"https://api.github.com/users/mosic/following{/other_user}","gists_url":"https://api.github.com/users/mosic/gists{/gist_id}","starred_url":"https://api.github.com/users/mosic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosic/subscriptions","organizations_url":"https://api.github.com/users/mosic/orgs","repos_url":"https://api.github.com/users/mosic/repos","events_url":"https://api.github.com/users/mosic/events{/privacy}","received_events_url":"https://api.github.com/users/mosic/received_events","type":"User","site_admin":false},"body":"Line up pipes with `share_request`.","created_at":"2016-06-20T15:16:14Z","updated_at":"2016-06-20T15:16:14Z","html_url":"https://github.com/evercam/evercam-media/pull/255#discussion_r67707989","pull_request_url":"https://api.github.com/repos/evercam/evercam-media/pulls/255","_links":{"self":{"href":"https://api.github.com/repos/evercam/evercam-media/pulls/comments/67707989"},"html":{"href":"https://github.com/evercam/evercam-media/pull/255#discussion_r67707989"},"pull_request":{"href":"https://api.github.com/repos/evercam/evercam-media/pulls/255"}}},"pull_request":{"url":"https://api.github.com/repos/evercam/evercam-media/pulls/255","id":73878893,"html_url":"https://github.com/evercam/evercam-media/pull/255","diff_url":"https://github.com/evercam/evercam-media/pull/255.diff","patch_url":"https://github.com/evercam/evercam-media/pull/255.patch","issue_url":"https://api.github.com/repos/evercam/evercam-media/issues/255","number":255,"state":"open","locked":false,"title":"Added create share / share-request endpoint","user":{"login":"azharmalik3","id":6176136,"avatar_url":"https://avatars.githubusercontent.com/u/6176136?v=3","gravatar_id":"","url":"https://api.github.com/users/azharmalik3","html_url":"https://github.com/azharmalik3","followers_url":"https://api.github.com/users/azharmalik3/followers","following_url":"https://api.github.com/users/azharmalik3/following{/other_user}","gists_url":"https://api.github.com/users/azharmalik3/gists{/gist_id}","starred_url":"https://api.github.com/users/azharmalik3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azharmalik3/subscriptions","organizations_url":"https://api.github.com/users/azharmalik3/orgs","repos_url":"https://api.github.com/users/azharmalik3/repos","events_url":"https://api.github.com/users/azharmalik3/events{/privacy}","received_events_url":"https://api.github.com/users/azharmalik3/received_events","type":"User","site_admin":false},"body":"@mosic ","created_at":"2016-06-15T09:29:15Z","updated_at":"2016-06-20T15:16:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f1dc00b02f5c38957a8ffce41aed00ddf6d645f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/evercam/evercam-media/pulls/255/commits","review_comments_url":"https://api.github.com/repos/evercam/evercam-media/pulls/255/comments","review_comment_url":"https://api.github.com/repos/evercam/evercam-media/pulls/comments{/number}","comments_url":"https://api.github.com/repos/evercam/evercam-media/issues/255/comments","statuses_url":"https://api.github.com/repos/evercam/evercam-media/statuses/020756fb5e135aaa0f5af7b5a70dcf9f03facc36","head":{"label":"evercam:create_share","ref":"create_share","sha":"020756fb5e135aaa0f5af7b5a70dcf9f03facc36","user":{"login":"evercam","id":5575404,"avatar_url":"https://avatars.githubusercontent.com/u/5575404?v=3","gravatar_id":"","url":"https://api.github.com/users/evercam","html_url":"https://github.com/evercam","followers_url":"https://api.github.com/users/evercam/followers","following_url":"https://api.github.com/users/evercam/following{/other_user}","gists_url":"https://api.github.com/users/evercam/gists{/gist_id}","starred_url":"https://api.github.com/users/evercam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evercam/subscriptions","organizations_url":"https://api.github.com/users/evercam/orgs","repos_url":"https://api.github.com/users/evercam/repos","events_url":"https://api.github.com/users/evercam/events{/privacy}","received_events_url":"https://api.github.com/users/evercam/received_events","type":"Organization","site_admin":false},"repo":{"id":32446226,"name":"evercam-media","full_name":"evercam/evercam-media","owner":{"login":"evercam","id":5575404,"avatar_url":"https://avatars.githubusercontent.com/u/5575404?v=3","gravatar_id":"","url":"https://api.github.com/users/evercam","html_url":"https://github.com/evercam","followers_url":"https://api.github.com/users/evercam/followers","following_url":"https://api.github.com/users/evercam/following{/other_user}","gists_url":"https://api.github.com/users/evercam/gists{/gist_id}","starred_url":"https://api.github.com/users/evercam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evercam/subscriptions","organizations_url":"https://api.github.com/users/evercam/orgs","repos_url":"https://api.github.com/users/evercam/repos","events_url":"https://api.github.com/users/evercam/events{/privacy}","received_events_url":"https://api.github.com/users/evercam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/evercam/evercam-media","description":"Proxy between Cameras, the API, Storage & Clients.","fork":false,"url":"https://api.github.com/repos/evercam/evercam-media","forks_url":"https://api.github.com/repos/evercam/evercam-media/forks","keys_url":"https://api.github.com/repos/evercam/evercam-media/keys{/key_id}","collaborators_url":"https://api.github.com/repos/evercam/evercam-media/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/evercam/evercam-media/teams","hooks_url":"https://api.github.com/repos/evercam/evercam-media/hooks","issue_events_url":"https://api.github.com/repos/evercam/evercam-media/issues/events{/number}","events_url":"https://api.github.com/repos/evercam/evercam-media/events","assignees_url":"https://api.github.com/repos/evercam/evercam-media/assignees{/user}","branches_url":"https://api.github.com/repos/evercam/evercam-media/branches{/branch}","tags_url":"https://api.github.com/repos/evercam/evercam-media/tags","blobs_url":"https://api.github.com/repos/evercam/evercam-media/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/evercam/evercam-media/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/evercam/evercam-media/git/refs{/sha}","trees_url":"https://api.github.com/repos/evercam/evercam-media/git/trees{/sha}","statuses_url":"https://api.github.com/repos/evercam/evercam-media/statuses/{sha}","languages_url":"https://api.github.com/repos/evercam/evercam-media/languages","stargazers_url":"https://api.github.com/repos/evercam/evercam-media/stargazers","contributors_url":"https://api.github.com/repos/evercam/evercam-media/contributors","subscribers_url":"https://api.github.com/repos/evercam/evercam-media/subscribers","subscription_url":"https://api.github.com/repos/evercam/evercam-media/subscription","commits_url":"https://api.github.com/repos/evercam/evercam-media/commits{/sha}","git_commits_url":"https://api.github.com/repos/evercam/evercam-media/git/commits{/sha}","comments_url":"https://api.github.com/repos/evercam/evercam-media/comments{/number}","issue_comment_url":"https://api.github.com/repos/evercam/evercam-media/issues/comments{/number}","contents_url":"https://api.github.com/repos/evercam/evercam-media/contents/{+path}","compare_url":"https://api.github.com/repos/evercam/evercam-media/compare/{base}...{head}","merges_url":"https://api.github.com/repos/evercam/evercam-media/merges","archive_url":"https://api.github.com/repos/evercam/evercam-media/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/evercam/evercam-media/downloads","issues_url":"https://api.github.com/repos/evercam/evercam-media/issues{/number}","pulls_url":"https://api.github.com/repos/evercam/evercam-media/pulls{/number}","milestones_url":"https://api.github.com/repos/evercam/evercam-media/milestones{/number}","notifications_url":"https://api.github.com/repos/evercam/evercam-media/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/evercam/evercam-media/labels{/name}","releases_url":"https://api.github.com/repos/evercam/evercam-media/releases{/id}","deployments_url":"https://api.github.com/repos/evercam/evercam-media/deployments","created_at":"2015-03-18T08:16:19Z","updated_at":"2016-06-07T00:35:32Z","pushed_at":"2016-06-20T14:48:06Z","git_url":"git://github.com/evercam/evercam-media.git","ssh_url":"git@github.com:evercam/evercam-media.git","clone_url":"https://github.com/evercam/evercam-media.git","svn_url":"https://github.com/evercam/evercam-media","homepage":"https://media.evercam.io/","size":1442,"stargazers_count":30,"watchers_count":30,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":78,"forks":8,"open_issues":78,"watchers":30,"default_branch":"master"}},"base":{"label":"evercam:master","ref":"master","sha":"7ba51dcdabb9192438372d4573803d5f716738c5","user":{"login":"evercam","id":5575404,"avatar_url":"https://avatars.githubusercontent.com/u/5575404?v=3","gravatar_id":"","url":"https://api.github.com/users/evercam","html_url":"https://github.com/evercam","followers_url":"https://api.github.com/users/evercam/followers","following_url":"https://api.github.com/users/evercam/following{/other_user}","gists_url":"https://api.github.com/users/evercam/gists{/gist_id}","starred_url":"https://api.github.com/users/evercam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evercam/subscriptions","organizations_url":"https://api.github.com/users/evercam/orgs","repos_url":"https://api.github.com/users/evercam/repos","events_url":"https://api.github.com/users/evercam/events{/privacy}","received_events_url":"https://api.github.com/users/evercam/received_events","type":"Organization","site_admin":false},"repo":{"id":32446226,"name":"evercam-media","full_name":"evercam/evercam-media","owner":{"login":"evercam","id":5575404,"avatar_url":"https://avatars.githubusercontent.com/u/5575404?v=3","gravatar_id":"","url":"https://api.github.com/users/evercam","html_url":"https://github.com/evercam","followers_url":"https://api.github.com/users/evercam/followers","following_url":"https://api.github.com/users/evercam/following{/other_user}","gists_url":"https://api.github.com/users/evercam/gists{/gist_id}","starred_url":"https://api.github.com/users/evercam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evercam/subscriptions","organizations_url":"https://api.github.com/users/evercam/orgs","repos_url":"https://api.github.com/users/evercam/repos","events_url":"https://api.github.com/users/evercam/events{/privacy}","received_events_url":"https://api.github.com/users/evercam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/evercam/evercam-media","description":"Proxy between Cameras, the API, Storage & Clients.","fork":false,"url":"https://api.github.com/repos/evercam/evercam-media","forks_url":"https://api.github.com/repos/evercam/evercam-media/forks","keys_url":"https://api.github.com/repos/evercam/evercam-media/keys{/key_id}","collaborators_url":"https://api.github.com/repos/evercam/evercam-media/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/evercam/evercam-media/teams","hooks_url":"https://api.github.com/repos/evercam/evercam-media/hooks","issue_events_url":"https://api.github.com/repos/evercam/evercam-media/issues/events{/number}","events_url":"https://api.github.com/repos/evercam/evercam-media/events","assignees_url":"https://api.github.com/repos/evercam/evercam-media/assignees{/user}","branches_url":"https://api.github.com/repos/evercam/evercam-media/branches{/branch}","tags_url":"https://api.github.com/repos/evercam/evercam-media/tags","blobs_url":"https://api.github.com/repos/evercam/evercam-media/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/evercam/evercam-media/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/evercam/evercam-media/git/refs{/sha}","trees_url":"https://api.github.com/repos/evercam/evercam-media/git/trees{/sha}","statuses_url":"https://api.github.com/repos/evercam/evercam-media/statuses/{sha}","languages_url":"https://api.github.com/repos/evercam/evercam-media/languages","stargazers_url":"https://api.github.com/repos/evercam/evercam-media/stargazers","contributors_url":"https://api.github.com/repos/evercam/evercam-media/contributors","subscribers_url":"https://api.github.com/repos/evercam/evercam-media/subscribers","subscription_url":"https://api.github.com/repos/evercam/evercam-media/subscription","commits_url":"https://api.github.com/repos/evercam/evercam-media/commits{/sha}","git_commits_url":"https://api.github.com/repos/evercam/evercam-media/git/commits{/sha}","comments_url":"https://api.github.com/repos/evercam/evercam-media/comments{/number}","issue_comment_url":"https://api.github.com/repos/evercam/evercam-media/issues/comments{/number}","contents_url":"https://api.github.com/repos/evercam/evercam-media/contents/{+path}","compare_url":"https://api.github.com/repos/evercam/evercam-media/compare/{base}...{head}","merges_url":"https://api.github.com/repos/evercam/evercam-media/merges","archive_url":"https://api.github.com/repos/evercam/evercam-media/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/evercam/evercam-media/downloads","issues_url":"https://api.github.com/repos/evercam/evercam-media/issues{/number}","pulls_url":"https://api.github.com/repos/evercam/evercam-media/pulls{/number}","milestones_url":"https://api.github.com/repos/evercam/evercam-media/milestones{/number}","notifications_url":"https://api.github.com/repos/evercam/evercam-media/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/evercam/evercam-media/labels{/name}","releases_url":"https://api.github.com/repos/evercam/evercam-media/releases{/id}","deployments_url":"https://api.github.com/repos/evercam/evercam-media/deployments","created_at":"2015-03-18T08:16:19Z","updated_at":"2016-06-07T00:35:32Z","pushed_at":"2016-06-20T14:48:06Z","git_url":"git://github.com/evercam/evercam-media.git","ssh_url":"git@github.com:evercam/evercam-media.git","clone_url":"https://github.com/evercam/evercam-media.git","svn_url":"https://github.com/evercam/evercam-media","homepage":"https://media.evercam.io/","size":1442,"stargazers_count":30,"watchers_count":30,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":78,"forks":8,"open_issues":78,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/evercam/evercam-media/pulls/255"},"html":{"href":"https://github.com/evercam/evercam-media/pull/255"},"issue":{"href":"https://api.github.com/repos/evercam/evercam-media/issues/255"},"comments":{"href":"https://api.github.com/repos/evercam/evercam-media/issues/255/comments"},"review_comments":{"href":"https://api.github.com/repos/evercam/evercam-media/pulls/255/comments"},"review_comment":{"href":"https://api.github.com/repos/evercam/evercam-media/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/evercam/evercam-media/pulls/255/commits"},"statuses":{"href":"https://api.github.com/repos/evercam/evercam-media/statuses/020756fb5e135aaa0f5af7b5a70dcf9f03facc36"}}}}
{"actor":{"display_login":"mosic"}}