{"action":"created","comment":{"url":"https://api.github.com/repos/esl/MongooseIM/pulls/comments/47878063","id":47878063,"diff_hunk":"@@ -0,0 +1,166 @@\n+%%==============================================================================\n+%% Copyright 2015 Guillaume Bour.\n+%%\n+%% Licensed under the Apache License, Version 2.0 (the \"License\");\n+%% you may not use this file except in compliance with the License.\n+%% You may obtain a copy of the License at\n+%%\n+%% http://www.apache.org/licenses/LICENSE-2.0\n+%%\n+%% Unless required by applicable law or agreed to in writing, software\n+%% distributed under the License is distributed on an \"AS IS\" BASIS,\n+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+%% See the License for the specific language governing permissions and\n+%% limitations under the License.\n+%%==============================================================================\n+\n+%\n+% NOTES:\n+%   user default privacy is stored in bucket {<<\"privacy_defaults\">>, LServer}, key LUser\n+%   user privacy lists names are stored in set {<<\"privacy_lists_names\">>, <<\"LServer\">>}, key LUser\n+%   user privace lists content are stored in bucket {<<\"privacy_lists\">>, LServer}, key <<LUser,$/,ListName>>\n+\n+-module(mod_privacy_riak).\n+-author('guillaume@bour.cc').\n+-behaviour(mod_privacy).\n+\n+-export([init/2,\n+         get_default_list/2,\n+         get_list_names/2,\n+         get_privacy_list/3,\n+         forget_default_list/2,\n+         set_default_list/3,\n+         remove_privacy_list/3,\n+         replace_privacy_list/4,\n+         remove_user/2]).\n+\n+-include(\"ejabberd.hrl\").\n+-include(\"jlib.hrl\").\n+-include(\"mod_privacy.hrl\").\n+\n+-include_lib(\"riakc/include/riakc.hrl\").\n+\n+-define(BKT_DEFAULT_LIST(Server), {<<\"privacy_defaults\">>, Server}).\n+-define(BKT_LISTS_NAMES(Server), {<<\"privacy_lists_names\">>, Server}).\n+-define(BKT_LISTS(Server), {<<\"privacy_lists\">>, Server}).\n+\n+init(_Host, _Opts) ->\n+    ok.\n+\n+get_default_list(LUser, LServer) ->\n+    case get_default_list_name(LUser, LServer) of\n+        none ->\n+            {error, not_found};\n+        Default ->\n+            case get_privacy_list(LUser, LServer, Default) of\n+                {ok, List} ->\n+                    {ok, {Default, List}};\n+                {error, Reason} ->\n+                    {error, Reason}\n+            end\n+    end.\n+\n+get_list_names(LUser, LServer) ->\n+    Default = get_default_list_name(LUser, LServer),\n+    Names = get_list_names_only(LUser, LServer),\n+    {ok, {Default, Names}}.\n+\n+get_default_list_name(LUser, LServer) ->\n+    case mongoose_riak:get(?BKT_DEFAULT_LIST(LServer), LUser) of\n+        {ok, Obj} ->\n+            riakc_obj:get_value(Obj);\n+\n+        _ -> none\n+    end.\n+\n+get_list_names_only(LUser, LServer) ->\n+    case mongoose_riak:fetch_type(?BKT_LISTS_NAMES(LServer), LUser) of\n+        {ok, Set} ->\n+            riakc_set:value(Set);\n+\n+        {error, {notfound, set}} ->\n+            [];\n+\n+        Err -> \n+            lager:error(\"~p\", [Err]),","path":"apps/ejabberd/src/mod_privacy_riak.erl","position":85,"original_position":85,"commit_id":"7b3a45fff406481f0b2f1e0778356e36ab90b828","original_commit_id":"7b3a45fff406481f0b2f1e0778356e36ab90b828","user":{"login":"michalwski","id":705828,"avatar_url":"https://avatars.githubusercontent.com/u/705828?v=3","gravatar_id":"","url":"https://api.github.com/users/michalwski","html_url":"https://github.com/michalwski","followers_url":"https://api.github.com/users/michalwski/followers","following_url":"https://api.github.com/users/michalwski/following{/other_user}","gists_url":"https://api.github.com/users/michalwski/gists{/gist_id}","starred_url":"https://api.github.com/users/michalwski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalwski/subscriptions","organizations_url":"https://api.github.com/users/michalwski/orgs","repos_url":"https://api.github.com/users/michalwski/repos","events_url":"https://api.github.com/users/michalwski/events{/privacy}","received_events_url":"https://api.github.com/users/michalwski/received_events","type":"User","site_admin":false},"body":"Please use macro `?ERROR_MSG` defined in `ejabberd.hrl` file to be more consistent.","created_at":"2015-12-17T07:58:08Z","updated_at":"2015-12-17T07:58:08Z","html_url":"https://github.com/esl/MongooseIM/pull/618#discussion_r47878063","pull_request_url":"https://api.github.com/repos/esl/MongooseIM/pulls/618","_links":{"self":{"href":"https://api.github.com/repos/esl/MongooseIM/pulls/comments/47878063"},"html":{"href":"https://github.com/esl/MongooseIM/pull/618#discussion_r47878063"},"pull_request":{"href":"https://api.github.com/repos/esl/MongooseIM/pulls/618"}}},"pull_request":{"url":"https://api.github.com/repos/esl/MongooseIM/pulls/618","id":53509928,"html_url":"https://github.com/esl/MongooseIM/pull/618","diff_url":"https://github.com/esl/MongooseIM/pull/618.diff","patch_url":"https://github.com/esl/MongooseIM/pull/618.patch","issue_url":"https://api.github.com/repos/esl/MongooseIM/issues/618","number":618,"state":"open","locked":false,"title":"Support riak backend in mod_privacy module","user":{"login":"gbour","id":644293,"avatar_url":"https://avatars.githubusercontent.com/u/644293?v=3","gravatar_id":"","url":"https://api.github.com/users/gbour","html_url":"https://github.com/gbour","followers_url":"https://api.github.com/users/gbour/followers","following_url":"https://api.github.com/users/gbour/following{/other_user}","gists_url":"https://api.github.com/users/gbour/gists{/gist_id}","starred_url":"https://api.github.com/users/gbour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbour/subscriptions","organizations_url":"https://api.github.com/users/gbour/orgs","repos_url":"https://api.github.com/users/gbour/repos","events_url":"https://api.github.com/users/gbour/events{/privacy}","received_events_url":"https://api.github.com/users/gbour/received_events","type":"User","site_admin":false},"body":"see #585 ","created_at":"2015-12-13T21:16:17Z","updated_at":"2015-12-17T07:58:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ecaa96a671c15fafdd737c15760e8a238a50e4ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/esl/MongooseIM/pulls/618/commits","review_comments_url":"https://api.github.com/repos/esl/MongooseIM/pulls/618/comments","review_comment_url":"https://api.github.com/repos/esl/MongooseIM/pulls/comments{/number}","comments_url":"https://api.github.com/repos/esl/MongooseIM/issues/618/comments","statuses_url":"https://api.github.com/repos/esl/MongooseIM/statuses/7b3a45fff406481f0b2f1e0778356e36ab90b828","head":{"label":"gbour:master","ref":"master","sha":"7b3a45fff406481f0b2f1e0778356e36ab90b828","user":{"login":"gbour","id":644293,"avatar_url":"https://avatars.githubusercontent.com/u/644293?v=3","gravatar_id":"","url":"https://api.github.com/users/gbour","html_url":"https://github.com/gbour","followers_url":"https://api.github.com/users/gbour/followers","following_url":"https://api.github.com/users/gbour/following{/other_user}","gists_url":"https://api.github.com/users/gbour/gists{/gist_id}","starred_url":"https://api.github.com/users/gbour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbour/subscriptions","organizations_url":"https://api.github.com/users/gbour/orgs","repos_url":"https://api.github.com/users/gbour/repos","events_url":"https://api.github.com/users/gbour/events{/privacy}","received_events_url":"https://api.github.com/users/gbour/received_events","type":"User","site_admin":false},"repo":{"id":47812931,"name":"MongooseIM","full_name":"gbour/MongooseIM","owner":{"login":"gbour","id":644293,"avatar_url":"https://avatars.githubusercontent.com/u/644293?v=3","gravatar_id":"","url":"https://api.github.com/users/gbour","html_url":"https://github.com/gbour","followers_url":"https://api.github.com/users/gbour/followers","following_url":"https://api.github.com/users/gbour/following{/other_user}","gists_url":"https://api.github.com/users/gbour/gists{/gist_id}","starred_url":"https://api.github.com/users/gbour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbour/subscriptions","organizations_url":"https://api.github.com/users/gbour/orgs","repos_url":"https://api.github.com/users/gbour/repos","events_url":"https://api.github.com/users/gbour/events{/privacy}","received_events_url":"https://api.github.com/users/gbour/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gbour/MongooseIM","description":"Jabber / XMPP server with focus on performance and scalability, by Erlang Solutions","fork":true,"url":"https://api.github.com/repos/gbour/MongooseIM","forks_url":"https://api.github.com/repos/gbour/MongooseIM/forks","keys_url":"https://api.github.com/repos/gbour/MongooseIM/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gbour/MongooseIM/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gbour/MongooseIM/teams","hooks_url":"https://api.github.com/repos/gbour/MongooseIM/hooks","issue_events_url":"https://api.github.com/repos/gbour/MongooseIM/issues/events{/number}","events_url":"https://api.github.com/repos/gbour/MongooseIM/events","assignees_url":"https://api.github.com/repos/gbour/MongooseIM/assignees{/user}","branches_url":"https://api.github.com/repos/gbour/MongooseIM/branches{/branch}","tags_url":"https://api.github.com/repos/gbour/MongooseIM/tags","blobs_url":"https://api.github.com/repos/gbour/MongooseIM/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gbour/MongooseIM/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gbour/MongooseIM/git/refs{/sha}","trees_url":"https://api.github.com/repos/gbour/MongooseIM/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gbour/MongooseIM/statuses/{sha}","languages_url":"https://api.github.com/repos/gbour/MongooseIM/languages","stargazers_url":"https://api.github.com/repos/gbour/MongooseIM/stargazers","contributors_url":"https://api.github.com/repos/gbour/MongooseIM/contributors","subscribers_url":"https://api.github.com/repos/gbour/MongooseIM/subscribers","subscription_url":"https://api.github.com/repos/gbour/MongooseIM/subscription","commits_url":"https://api.github.com/repos/gbour/MongooseIM/commits{/sha}","git_commits_url":"https://api.github.com/repos/gbour/MongooseIM/git/commits{/sha}","comments_url":"https://api.github.com/repos/gbour/MongooseIM/comments{/number}","issue_comment_url":"https://api.github.com/repos/gbour/MongooseIM/issues/comments{/number}","contents_url":"https://api.github.com/repos/gbour/MongooseIM/contents/{+path}","compare_url":"https://api.github.com/repos/gbour/MongooseIM/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gbour/MongooseIM/merges","archive_url":"https://api.github.com/repos/gbour/MongooseIM/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gbour/MongooseIM/downloads","issues_url":"https://api.github.com/repos/gbour/MongooseIM/issues{/number}","pulls_url":"https://api.github.com/repos/gbour/MongooseIM/pulls{/number}","milestones_url":"https://api.github.com/repos/gbour/MongooseIM/milestones{/number}","notifications_url":"https://api.github.com/repos/gbour/MongooseIM/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gbour/MongooseIM/labels{/name}","releases_url":"https://api.github.com/repos/gbour/MongooseIM/releases{/id}","created_at":"2015-12-11T07:54:04Z","updated_at":"2015-12-11T07:54:06Z","pushed_at":"2015-12-16T18:38:59Z","git_url":"git://github.com/gbour/MongooseIM.git","ssh_url":"git@github.com:gbour/MongooseIM.git","clone_url":"https://github.com/gbour/MongooseIM.git","svn_url":"https://github.com/gbour/MongooseIM","homepage":"https://www.erlang-solutions.com/products/mongooseim.html","size":14788,"stargazers_count":0,"watchers_count":0,"language":"Erlang","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"esl:master","ref":"master","sha":"97c016917137d5748919815fbc1c6686d508b38b","user":{"login":"esl","id":283412,"avatar_url":"https://avatars.githubusercontent.com/u/283412?v=3","gravatar_id":"","url":"https://api.github.com/users/esl","html_url":"https://github.com/esl","followers_url":"https://api.github.com/users/esl/followers","following_url":"https://api.github.com/users/esl/following{/other_user}","gists_url":"https://api.github.com/users/esl/gists{/gist_id}","starred_url":"https://api.github.com/users/esl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esl/subscriptions","organizations_url":"https://api.github.com/users/esl/orgs","repos_url":"https://api.github.com/users/esl/repos","events_url":"https://api.github.com/users/esl/events{/privacy}","received_events_url":"https://api.github.com/users/esl/received_events","type":"Organization","site_admin":false},"repo":{"id":2354240,"name":"MongooseIM","full_name":"esl/MongooseIM","owner":{"login":"esl","id":283412,"avatar_url":"https://avatars.githubusercontent.com/u/283412?v=3","gravatar_id":"","url":"https://api.github.com/users/esl","html_url":"https://github.com/esl","followers_url":"https://api.github.com/users/esl/followers","following_url":"https://api.github.com/users/esl/following{/other_user}","gists_url":"https://api.github.com/users/esl/gists{/gist_id}","starred_url":"https://api.github.com/users/esl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esl/subscriptions","organizations_url":"https://api.github.com/users/esl/orgs","repos_url":"https://api.github.com/users/esl/repos","events_url":"https://api.github.com/users/esl/events{/privacy}","received_events_url":"https://api.github.com/users/esl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/esl/MongooseIM","description":"Jabber / XMPP server with focus on performance and scalability, by Erlang Solutions","fork":false,"url":"https://api.github.com/repos/esl/MongooseIM","forks_url":"https://api.github.com/repos/esl/MongooseIM/forks","keys_url":"https://api.github.com/repos/esl/MongooseIM/keys{/key_id}","collaborators_url":"https://api.github.com/repos/esl/MongooseIM/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/esl/MongooseIM/teams","hooks_url":"https://api.github.com/repos/esl/MongooseIM/hooks","issue_events_url":"https://api.github.com/repos/esl/MongooseIM/issues/events{/number}","events_url":"https://api.github.com/repos/esl/MongooseIM/events","assignees_url":"https://api.github.com/repos/esl/MongooseIM/assignees{/user}","branches_url":"https://api.github.com/repos/esl/MongooseIM/branches{/branch}","tags_url":"https://api.github.com/repos/esl/MongooseIM/tags","blobs_url":"https://api.github.com/repos/esl/MongooseIM/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/esl/MongooseIM/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/esl/MongooseIM/git/refs{/sha}","trees_url":"https://api.github.com/repos/esl/MongooseIM/git/trees{/sha}","statuses_url":"https://api.github.com/repos/esl/MongooseIM/statuses/{sha}","languages_url":"https://api.github.com/repos/esl/MongooseIM/languages","stargazers_url":"https://api.github.com/repos/esl/MongooseIM/stargazers","contributors_url":"https://api.github.com/repos/esl/MongooseIM/contributors","subscribers_url":"https://api.github.com/repos/esl/MongooseIM/subscribers","subscription_url":"https://api.github.com/repos/esl/MongooseIM/subscription","commits_url":"https://api.github.com/repos/esl/MongooseIM/commits{/sha}","git_commits_url":"https://api.github.com/repos/esl/MongooseIM/git/commits{/sha}","comments_url":"https://api.github.com/repos/esl/MongooseIM/comments{/number}","issue_comment_url":"https://api.github.com/repos/esl/MongooseIM/issues/comments{/number}","contents_url":"https://api.github.com/repos/esl/MongooseIM/contents/{+path}","compare_url":"https://api.github.com/repos/esl/MongooseIM/compare/{base}...{head}","merges_url":"https://api.github.com/repos/esl/MongooseIM/merges","archive_url":"https://api.github.com/repos/esl/MongooseIM/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/esl/MongooseIM/downloads","issues_url":"https://api.github.com/repos/esl/MongooseIM/issues{/number}","pulls_url":"https://api.github.com/repos/esl/MongooseIM/pulls{/number}","milestones_url":"https://api.github.com/repos/esl/MongooseIM/milestones{/number}","notifications_url":"https://api.github.com/repos/esl/MongooseIM/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/esl/MongooseIM/labels{/name}","releases_url":"https://api.github.com/repos/esl/MongooseIM/releases{/id}","created_at":"2011-09-09T08:19:18Z","updated_at":"2015-12-15T23:52:05Z","pushed_at":"2015-12-16T18:39:00Z","git_url":"git://github.com/esl/MongooseIM.git","ssh_url":"git@github.com:esl/MongooseIM.git","clone_url":"https://github.com/esl/MongooseIM.git","svn_url":"https://github.com/esl/MongooseIM","homepage":"https://www.erlang-solutions.com/products/mongooseim.html","size":15563,"stargazers_count":446,"watchers_count":446,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":181,"mirror_url":null,"open_issues_count":53,"forks":181,"open_issues":53,"watchers":446,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/esl/MongooseIM/pulls/618"},"html":{"href":"https://github.com/esl/MongooseIM/pull/618"},"issue":{"href":"https://api.github.com/repos/esl/MongooseIM/issues/618"},"comments":{"href":"https://api.github.com/repos/esl/MongooseIM/issues/618/comments"},"review_comments":{"href":"https://api.github.com/repos/esl/MongooseIM/pulls/618/comments"},"review_comment":{"href":"https://api.github.com/repos/esl/MongooseIM/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/esl/MongooseIM/pulls/618/commits"},"statuses":{"href":"https://api.github.com/repos/esl/MongooseIM/statuses/7b3a45fff406481f0b2f1e0778356e36ab90b828"}}}}