{"action":"created","comment":{"url":"https://api.github.com/repos/operable/cog/pulls/comments/92872540","pull_request_review_id":13397251,"id":92872540,"diff_hunk":"@@ -0,0 +1,38 @@\n+defmodule Cog.Commands.Alias do\n+  alias Cog.Repo\n+  alias Cog.Commands.Helpers\n+  alias Cog.Models.{UserCommandAlias, SiteCommandAlias}\n+\n+  def error(errors) when is_list(errors),\n+    do: Enum.map_join(errors, \"\\n\", &error/1)\n+  def error(:alias_in_user),\n+    do: \"Alias is already in the 'user' namespace.\"\n+  def error(:alias_in_site),\n+    do: \"Alias is already in the 'site' namespace.\"\n+  def error({:alias_not_found, alias}),\n+    do: \"I can't find '#{alias}'. Please try again\"\n+  def error(:bad_pattern),\n+    do: \"Invalid alias name. Only emoji, letters, numbers, and the following special characters are allowed: *, -, _\"\n+  def error(:too_many_wildcards),\n+    do: \"Too many wildcards. You can only include one wildcard in a query\"\n+  def error(error),\n+    do: Helpers.error(error)\n+\n+  @doc \"\"\"\n+  Returns an alias. If the visibility isn't passed we first search for a user\n+  alias and if that isn't found we search for a site alias.\n+  \"\"\"\n+  def get_command_alias(user_id, \"user:\" <> user_alias),\n+    do: Repo.get_by(UserCommandAlias, name: user_alias, user_id: user_id)\n+  def get_command_alias(_, \"site:\" <> site_alias),\n+    do: Repo.get_by(SiteCommandAlias, name: site_alias)\n+  def get_command_alias(user_id, alias) do\n+    case get_command_alias(user_id, \"user:#{alias}\") do\n+      nil ->\n+        get_command_alias(user_id, \"site:#{alias}\")\n+      src_alias ->\n+        src_alias\n+    end","path":"lib/cog/commands/alias.ex","position":35,"original_position":35,"commit_id":"28c32972830098fd8a76067e910e011cc3877d13","original_commit_id":"28c32972830098fd8a76067e910e011cc3877d13","user":{"login":"vanstee","id":228734,"avatar_url":"https://avatars.githubusercontent.com/u/228734?v=3","gravatar_id":"","url":"https://api.github.com/users/vanstee","html_url":"https://github.com/vanstee","followers_url":"https://api.github.com/users/vanstee/followers","following_url":"https://api.github.com/users/vanstee/following{/other_user}","gists_url":"https://api.github.com/users/vanstee/gists{/gist_id}","starred_url":"https://api.github.com/users/vanstee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanstee/subscriptions","organizations_url":"https://api.github.com/users/vanstee/orgs","repos_url":"https://api.github.com/users/vanstee/repos","events_url":"https://api.github.com/users/vanstee/events{/privacy}","received_events_url":"https://api.github.com/users/vanstee/received_events","type":"User","site_admin":false},"body":"I approved the PR so this is just a style question, but is the following less favored in functional programming? I just see it all the time in Ruby and liked the pattern. Not advocating a change here, just curious.\r\n\r\n```elixir\r\nget_command_alias(user_id, \"user:#{alias}\") ||\r\n  get_command_alias(user_id, \"site:#{alias}\")\r\n```","created_at":"2016-12-16T19:35:31Z","updated_at":"2016-12-16T19:35:31Z","html_url":"https://github.com/operable/cog/pull/1258#discussion_r92872540","pull_request_url":"https://api.github.com/repos/operable/cog/pulls/1258","_links":{"self":{"href":"https://api.github.com/repos/operable/cog/pulls/comments/92872540"},"html":{"href":"https://github.com/operable/cog/pull/1258#discussion_r92872540"},"pull_request":{"href":"https://api.github.com/repos/operable/cog/pulls/1258"}}},"pull_request":{"url":"https://api.github.com/repos/operable/cog/pulls/1258","id":98381504,"html_url":"https://github.com/operable/cog/pull/1258","diff_url":"https://github.com/operable/cog/pull/1258.diff","patch_url":"https://github.com/operable/cog/pull/1258.patch","issue_url":"https://api.github.com/repos/operable/cog/issues/1258","number":1258,"state":"open","locked":false,"title":"command helpers cleanup","user":{"login":"mpeck","id":47858,"avatar_url":"https://avatars.githubusercontent.com/u/47858?v=3","gravatar_id":"","url":"https://api.github.com/users/mpeck","html_url":"https://github.com/mpeck","followers_url":"https://api.github.com/users/mpeck/followers","following_url":"https://api.github.com/users/mpeck/following{/other_user}","gists_url":"https://api.github.com/users/mpeck/gists{/gist_id}","starred_url":"https://api.github.com/users/mpeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpeck/subscriptions","organizations_url":"https://api.github.com/users/mpeck/orgs","repos_url":"https://api.github.com/users/mpeck/repos","events_url":"https://api.github.com/users/mpeck/events{/privacy}","received_events_url":"https://api.github.com/users/mpeck/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-16T18:30:27Z","updated_at":"2016-12-16T19:35:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24119c107e5eeaf101066770333fb37819dce12b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/operable/cog/pulls/1258/commits","review_comments_url":"https://api.github.com/repos/operable/cog/pulls/1258/comments","review_comment_url":"https://api.github.com/repos/operable/cog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/operable/cog/issues/1258/comments","statuses_url":"https://api.github.com/repos/operable/cog/statuses/28c32972830098fd8a76067e910e011cc3877d13","head":{"label":"operable:peck/cleanup","ref":"peck/cleanup","sha":"28c32972830098fd8a76067e910e011cc3877d13","user":{"login":"operable","id":6070463,"avatar_url":"https://avatars.githubusercontent.com/u/6070463?v=3","gravatar_id":"","url":"https://api.github.com/users/operable","html_url":"https://github.com/operable","followers_url":"https://api.github.com/users/operable/followers","following_url":"https://api.github.com/users/operable/following{/other_user}","gists_url":"https://api.github.com/users/operable/gists{/gist_id}","starred_url":"https://api.github.com/users/operable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/operable/subscriptions","organizations_url":"https://api.github.com/users/operable/orgs","repos_url":"https://api.github.com/users/operable/repos","events_url":"https://api.github.com/users/operable/events{/privacy}","received_events_url":"https://api.github.com/users/operable/received_events","type":"Organization","site_admin":false},"repo":{"id":49292670,"name":"cog","full_name":"operable/cog","owner":{"login":"operable","id":6070463,"avatar_url":"https://avatars.githubusercontent.com/u/6070463?v=3","gravatar_id":"","url":"https://api.github.com/users/operable","html_url":"https://github.com/operable","followers_url":"https://api.github.com/users/operable/followers","following_url":"https://api.github.com/users/operable/following{/other_user}","gists_url":"https://api.github.com/users/operable/gists{/gist_id}","starred_url":"https://api.github.com/users/operable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/operable/subscriptions","organizations_url":"https://api.github.com/users/operable/orgs","repos_url":"https://api.github.com/users/operable/repos","events_url":"https://api.github.com/users/operable/events{/privacy}","received_events_url":"https://api.github.com/users/operable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/operable/cog","description":"Bringing the power of the command line to chat","fork":false,"url":"https://api.github.com/repos/operable/cog","forks_url":"https://api.github.com/repos/operable/cog/forks","keys_url":"https://api.github.com/repos/operable/cog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/operable/cog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/operable/cog/teams","hooks_url":"https://api.github.com/repos/operable/cog/hooks","issue_events_url":"https://api.github.com/repos/operable/cog/issues/events{/number}","events_url":"https://api.github.com/repos/operable/cog/events","assignees_url":"https://api.github.com/repos/operable/cog/assignees{/user}","branches_url":"https://api.github.com/repos/operable/cog/branches{/branch}","tags_url":"https://api.github.com/repos/operable/cog/tags","blobs_url":"https://api.github.com/repos/operable/cog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/operable/cog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/operable/cog/git/refs{/sha}","trees_url":"https://api.github.com/repos/operable/cog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/operable/cog/statuses/{sha}","languages_url":"https://api.github.com/repos/operable/cog/languages","stargazers_url":"https://api.github.com/repos/operable/cog/stargazers","contributors_url":"https://api.github.com/repos/operable/cog/contributors","subscribers_url":"https://api.github.com/repos/operable/cog/subscribers","subscription_url":"https://api.github.com/repos/operable/cog/subscription","commits_url":"https://api.github.com/repos/operable/cog/commits{/sha}","git_commits_url":"https://api.github.com/repos/operable/cog/git/commits{/sha}","comments_url":"https://api.github.com/repos/operable/cog/comments{/number}","issue_comment_url":"https://api.github.com/repos/operable/cog/issues/comments{/number}","contents_url":"https://api.github.com/repos/operable/cog/contents/{+path}","compare_url":"https://api.github.com/repos/operable/cog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/operable/cog/merges","archive_url":"https://api.github.com/repos/operable/cog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/operable/cog/downloads","issues_url":"https://api.github.com/repos/operable/cog/issues{/number}","pulls_url":"https://api.github.com/repos/operable/cog/pulls{/number}","milestones_url":"https://api.github.com/repos/operable/cog/milestones{/number}","notifications_url":"https://api.github.com/repos/operable/cog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/operable/cog/labels{/name}","releases_url":"https://api.github.com/repos/operable/cog/releases{/id}","deployments_url":"https://api.github.com/repos/operable/cog/deployments","created_at":"2016-01-08T19:45:06Z","updated_at":"2016-12-14T18:36:17Z","pushed_at":"2016-12-16T18:51:56Z","git_url":"git://github.com/operable/cog.git","ssh_url":"git@github.com:operable/cog.git","clone_url":"https://github.com/operable/cog.git","svn_url":"https://github.com/operable/cog","homepage":"http://operable.io","size":4279,"stargazers_count":563,"watchers_count":563,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":101,"forks":39,"open_issues":101,"watchers":563,"default_branch":"master"}},"base":{"label":"operable:subcommand-rework-wip","ref":"subcommand-rework-wip","sha":"416bcfdf22e457249c07eabf5dcaea7b2f8e7c6c","user":{"login":"operable","id":6070463,"avatar_url":"https://avatars.githubusercontent.com/u/6070463?v=3","gravatar_id":"","url":"https://api.github.com/users/operable","html_url":"https://github.com/operable","followers_url":"https://api.github.com/users/operable/followers","following_url":"https://api.github.com/users/operable/following{/other_user}","gists_url":"https://api.github.com/users/operable/gists{/gist_id}","starred_url":"https://api.github.com/users/operable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/operable/subscriptions","organizations_url":"https://api.github.com/users/operable/orgs","repos_url":"https://api.github.com/users/operable/repos","events_url":"https://api.github.com/users/operable/events{/privacy}","received_events_url":"https://api.github.com/users/operable/received_events","type":"Organization","site_admin":false},"repo":{"id":49292670,"name":"cog","full_name":"operable/cog","owner":{"login":"operable","id":6070463,"avatar_url":"https://avatars.githubusercontent.com/u/6070463?v=3","gravatar_id":"","url":"https://api.github.com/users/operable","html_url":"https://github.com/operable","followers_url":"https://api.github.com/users/operable/followers","following_url":"https://api.github.com/users/operable/following{/other_user}","gists_url":"https://api.github.com/users/operable/gists{/gist_id}","starred_url":"https://api.github.com/users/operable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/operable/subscriptions","organizations_url":"https://api.github.com/users/operable/orgs","repos_url":"https://api.github.com/users/operable/repos","events_url":"https://api.github.com/users/operable/events{/privacy}","received_events_url":"https://api.github.com/users/operable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/operable/cog","description":"Bringing the power of the command line to chat","fork":false,"url":"https://api.github.com/repos/operable/cog","forks_url":"https://api.github.com/repos/operable/cog/forks","keys_url":"https://api.github.com/repos/operable/cog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/operable/cog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/operable/cog/teams","hooks_url":"https://api.github.com/repos/operable/cog/hooks","issue_events_url":"https://api.github.com/repos/operable/cog/issues/events{/number}","events_url":"https://api.github.com/repos/operable/cog/events","assignees_url":"https://api.github.com/repos/operable/cog/assignees{/user}","branches_url":"https://api.github.com/repos/operable/cog/branches{/branch}","tags_url":"https://api.github.com/repos/operable/cog/tags","blobs_url":"https://api.github.com/repos/operable/cog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/operable/cog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/operable/cog/git/refs{/sha}","trees_url":"https://api.github.com/repos/operable/cog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/operable/cog/statuses/{sha}","languages_url":"https://api.github.com/repos/operable/cog/languages","stargazers_url":"https://api.github.com/repos/operable/cog/stargazers","contributors_url":"https://api.github.com/repos/operable/cog/contributors","subscribers_url":"https://api.github.com/repos/operable/cog/subscribers","subscription_url":"https://api.github.com/repos/operable/cog/subscription","commits_url":"https://api.github.com/repos/operable/cog/commits{/sha}","git_commits_url":"https://api.github.com/repos/operable/cog/git/commits{/sha}","comments_url":"https://api.github.com/repos/operable/cog/comments{/number}","issue_comment_url":"https://api.github.com/repos/operable/cog/issues/comments{/number}","contents_url":"https://api.github.com/repos/operable/cog/contents/{+path}","compare_url":"https://api.github.com/repos/operable/cog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/operable/cog/merges","archive_url":"https://api.github.com/repos/operable/cog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/operable/cog/downloads","issues_url":"https://api.github.com/repos/operable/cog/issues{/number}","pulls_url":"https://api.github.com/repos/operable/cog/pulls{/number}","milestones_url":"https://api.github.com/repos/operable/cog/milestones{/number}","notifications_url":"https://api.github.com/repos/operable/cog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/operable/cog/labels{/name}","releases_url":"https://api.github.com/repos/operable/cog/releases{/id}","deployments_url":"https://api.github.com/repos/operable/cog/deployments","created_at":"2016-01-08T19:45:06Z","updated_at":"2016-12-14T18:36:17Z","pushed_at":"2016-12-16T18:51:56Z","git_url":"git://github.com/operable/cog.git","ssh_url":"git@github.com:operable/cog.git","clone_url":"https://github.com/operable/cog.git","svn_url":"https://github.com/operable/cog","homepage":"http://operable.io","size":4279,"stargazers_count":563,"watchers_count":563,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":101,"forks":39,"open_issues":101,"watchers":563,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/operable/cog/pulls/1258"},"html":{"href":"https://github.com/operable/cog/pull/1258"},"issue":{"href":"https://api.github.com/repos/operable/cog/issues/1258"},"comments":{"href":"https://api.github.com/repos/operable/cog/issues/1258/comments"},"review_comments":{"href":"https://api.github.com/repos/operable/cog/pulls/1258/comments"},"review_comment":{"href":"https://api.github.com/repos/operable/cog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/operable/cog/pulls/1258/commits"},"statuses":{"href":"https://api.github.com/repos/operable/cog/statuses/28c32972830098fd8a76067e910e011cc3877d13"}}}}
{"actor":{"display_login":"vanstee"}}