{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/social/pulls/comments/45470005","id":45470005,"diff_hunk":"@@ -0,0 +1,30 @@\n+# -*- coding: utf-8 -*-\n+# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza\n+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html\n+from openerp import models, api\n+from openerp.tools.safe_eval import safe_eval\n+\n+\n+class MailThread(models.AbstractModel):\n+    _inherit = 'mail.thread'\n+\n+    @api.model\n+    def _mail_restrict_follower_get_domain(self):\n+        parameter_name = 'mail_restrict_auto_follower.domain'\n+        return self.env['ir.config_parameter'].get_param(\n+            '%s.%s' % (parameter_name, self._name),\n+            default=self.env['ir.config_parameter'].get_param(\n+                parameter_name, default='[]'))\n+\n+    @api.multi\n+    def message_subscribe(self, partner_ids, subtype_ids=None):\n+        if self.env.context.get('allow_follower_subscription'):","path":"mail_restrict_auto_follower/models/mail_thread.py","position":21,"original_position":21,"commit_id":"44f2b93249b58566809b74b46be591f0d4515f6c","original_commit_id":"44f2b93249b58566809b74b46be591f0d4515f6c","user":{"login":"hbrunn","id":2563186,"avatar_url":"https://avatars.githubusercontent.com/u/2563186?v=3","gravatar_id":"","url":"https://api.github.com/users/hbrunn","html_url":"https://github.com/hbrunn","followers_url":"https://api.github.com/users/hbrunn/followers","following_url":"https://api.github.com/users/hbrunn/following{/other_user}","gists_url":"https://api.github.com/users/hbrunn/gists{/gist_id}","starred_url":"https://api.github.com/users/hbrunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbrunn/subscriptions","organizations_url":"https://api.github.com/users/hbrunn/orgs","repos_url":"https://api.github.com/users/hbrunn/repos","events_url":"https://api.github.com/users/hbrunn/events{/privacy}","received_events_url":"https://api.github.com/users/hbrunn/received_events","type":"User","site_admin":false},"body":"I think you should override https://github.com/OCA/OCB/blob/8.0/addons/mail/mail_thread.py#L1874 to set a context key there, and react to it here. This we, the default behavior is what standard does, and only when called by `message_auto_subscribe`, we do the filtering. This is safer.","created_at":"2015-11-20T13:51:54Z","updated_at":"2015-11-20T13:51:54Z","html_url":"https://github.com/OCA/social/pull/22#discussion_r45470005","pull_request_url":"https://api.github.com/repos/OCA/social/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/OCA/social/pulls/comments/45470005"},"html":{"href":"https://github.com/OCA/social/pull/22#discussion_r45470005"},"pull_request":{"href":"https://api.github.com/repos/OCA/social/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/social/pulls/22","id":47775827,"html_url":"https://github.com/OCA/social/pull/22","diff_url":"https://github.com/OCA/social/pull/22.diff","patch_url":"https://github.com/OCA/social/pull/22.patch","issue_url":"https://api.github.com/repos/OCA/social/issues/22","number":22,"state":"open","locked":false,"title":"[ADD] mail_restrict_auto_follower","user":{"login":"pedrobaeza","id":7165771,"avatar_url":"https://avatars.githubusercontent.com/u/7165771?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrobaeza","html_url":"https://github.com/pedrobaeza","followers_url":"https://api.github.com/users/pedrobaeza/followers","following_url":"https://api.github.com/users/pedrobaeza/following{/other_user}","gists_url":"https://api.github.com/users/pedrobaeza/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrobaeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrobaeza/subscriptions","organizations_url":"https://api.github.com/users/pedrobaeza/orgs","repos_url":"https://api.github.com/users/pedrobaeza/repos","events_url":"https://api.github.com/users/pedrobaeza/events{/privacy}","received_events_url":"https://api.github.com/users/pedrobaeza/received_events","type":"User","site_admin":false},"body":"========================================\r\nRestrict automatic follower subscription\r\n========================================\r\n\r\nThis module restricts the followers that are added automatically to a record.\r\nFor example, if you use the social ERP functions only internally, it makes\r\nsense to filter possible followers for being employees. Otherwise, you'll get\r\na quite crowded list of partners to choose from.\r\n\r\nConfiguration\r\n=============\r\n\r\nTo configure this module, you need to go to `System parameters` and adjust\r\n`mail_restrict_auto_follower.domain` with the domain to apply to the partners\r\ninvolved.\r\n\r\nThis will restrict followers globally. If you want to restrict only the\r\nfollowers for a certain record type (or have different restrictions for\r\ndifferent record types), create a parameter\r\n`mail_restrict_auto_follower.domain.$your_model`.\r\n\r\nAs an example, you may use `[('user_ids', '!=', False)]` to allow only\r\npartners that are also users to be added automatically as followers. This is\r\nalso the default.\r\n\r\nNote: This module won't change existing followers!\r\n\r\nKnown issues / Roadmap\r\n======================\r\n\r\n* Due to a problem in current API with inheritance, maybe some models ignore\r\n  the restriction. In that cases, a glue module is needed that redeclare the\r\n  the model this way:\r\n\r\n  ```python\r\n  class Model(models.Model):\r\n      _name = 'model'\r\n      _inherit = ['mail.thread', 'model']\r\n```\r\n\r\n* For v9, this should be merged with `mail_restrict_follower_selection`\r\n  module to have one module for both things that can be called\r\n  `mail_restrict_follower`.","created_at":"2015-10-15T11:48:02Z","updated_at":"2015-11-20T13:51:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f9761e66c75da4c00f2ddb9c213cb40ce72eed8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/social/pulls/22/commits","review_comments_url":"https://api.github.com/repos/OCA/social/pulls/22/comments","review_comment_url":"https://api.github.com/repos/OCA/social/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/social/issues/22/comments","statuses_url":"https://api.github.com/repos/OCA/social/statuses/44f2b93249b58566809b74b46be591f0d4515f6c","head":{"label":"pedrobaeza:8.0-mail_restrict_auto_follower","ref":"8.0-mail_restrict_auto_follower","sha":"44f2b93249b58566809b74b46be591f0d4515f6c","user":{"login":"pedrobaeza","id":7165771,"avatar_url":"https://avatars.githubusercontent.com/u/7165771?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrobaeza","html_url":"https://github.com/pedrobaeza","followers_url":"https://api.github.com/users/pedrobaeza/followers","following_url":"https://api.github.com/users/pedrobaeza/following{/other_user}","gists_url":"https://api.github.com/users/pedrobaeza/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrobaeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrobaeza/subscriptions","organizations_url":"https://api.github.com/users/pedrobaeza/orgs","repos_url":"https://api.github.com/users/pedrobaeza/repos","events_url":"https://api.github.com/users/pedrobaeza/events{/privacy}","received_events_url":"https://api.github.com/users/pedrobaeza/received_events","type":"User","site_admin":false},"repo":{"id":40143777,"name":"social","full_name":"pedrobaeza/social","owner":{"login":"pedrobaeza","id":7165771,"avatar_url":"https://avatars.githubusercontent.com/u/7165771?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrobaeza","html_url":"https://github.com/pedrobaeza","followers_url":"https://api.github.com/users/pedrobaeza/followers","following_url":"https://api.github.com/users/pedrobaeza/following{/other_user}","gists_url":"https://api.github.com/users/pedrobaeza/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrobaeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrobaeza/subscriptions","organizations_url":"https://api.github.com/users/pedrobaeza/orgs","repos_url":"https://api.github.com/users/pedrobaeza/repos","events_url":"https://api.github.com/users/pedrobaeza/events{/privacy}","received_events_url":"https://api.github.com/users/pedrobaeza/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pedrobaeza/social","description":"Addons concerning odoo's social ERP features and messaging in general","fork":true,"url":"https://api.github.com/repos/pedrobaeza/social","forks_url":"https://api.github.com/repos/pedrobaeza/social/forks","keys_url":"https://api.github.com/repos/pedrobaeza/social/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pedrobaeza/social/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pedrobaeza/social/teams","hooks_url":"https://api.github.com/repos/pedrobaeza/social/hooks","issue_events_url":"https://api.github.com/repos/pedrobaeza/social/issues/events{/number}","events_url":"https://api.github.com/repos/pedrobaeza/social/events","assignees_url":"https://api.github.com/repos/pedrobaeza/social/assignees{/user}","branches_url":"https://api.github.com/repos/pedrobaeza/social/branches{/branch}","tags_url":"https://api.github.com/repos/pedrobaeza/social/tags","blobs_url":"https://api.github.com/repos/pedrobaeza/social/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pedrobaeza/social/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pedrobaeza/social/git/refs{/sha}","trees_url":"https://api.github.com/repos/pedrobaeza/social/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pedrobaeza/social/statuses/{sha}","languages_url":"https://api.github.com/repos/pedrobaeza/social/languages","stargazers_url":"https://api.github.com/repos/pedrobaeza/social/stargazers","contributors_url":"https://api.github.com/repos/pedrobaeza/social/contributors","subscribers_url":"https://api.github.com/repos/pedrobaeza/social/subscribers","subscription_url":"https://api.github.com/repos/pedrobaeza/social/subscription","commits_url":"https://api.github.com/repos/pedrobaeza/social/commits{/sha}","git_commits_url":"https://api.github.com/repos/pedrobaeza/social/git/commits{/sha}","comments_url":"https://api.github.com/repos/pedrobaeza/social/comments{/number}","issue_comment_url":"https://api.github.com/repos/pedrobaeza/social/issues/comments{/number}","contents_url":"https://api.github.com/repos/pedrobaeza/social/contents/{+path}","compare_url":"https://api.github.com/repos/pedrobaeza/social/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pedrobaeza/social/merges","archive_url":"https://api.github.com/repos/pedrobaeza/social/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pedrobaeza/social/downloads","issues_url":"https://api.github.com/repos/pedrobaeza/social/issues{/number}","pulls_url":"https://api.github.com/repos/pedrobaeza/social/pulls{/number}","milestones_url":"https://api.github.com/repos/pedrobaeza/social/milestones{/number}","notifications_url":"https://api.github.com/repos/pedrobaeza/social/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pedrobaeza/social/labels{/name}","releases_url":"https://api.github.com/repos/pedrobaeza/social/releases{/id}","created_at":"2015-08-03T19:25:50Z","updated_at":"2015-07-18T07:15:01Z","pushed_at":"2015-11-05T23:14:20Z","git_url":"git://github.com/pedrobaeza/social.git","ssh_url":"git@github.com:pedrobaeza/social.git","clone_url":"https://github.com/pedrobaeza/social.git","svn_url":"https://github.com/pedrobaeza/social","homepage":null,"size":259,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"8.0"}},"base":{"label":"OCA:8.0","ref":"8.0","sha":"0e13473a530ee76899d4187510efa8bcddc97da1","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"repo":{"id":39009740,"name":"social","full_name":"OCA/social","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OCA/social","description":"Addons concerning odoo's social ERP features and messaging in general","fork":false,"url":"https://api.github.com/repos/OCA/social","forks_url":"https://api.github.com/repos/OCA/social/forks","keys_url":"https://api.github.com/repos/OCA/social/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/social/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/social/teams","hooks_url":"https://api.github.com/repos/OCA/social/hooks","issue_events_url":"https://api.github.com/repos/OCA/social/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/social/events","assignees_url":"https://api.github.com/repos/OCA/social/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/social/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/social/tags","blobs_url":"https://api.github.com/repos/OCA/social/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/social/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/social/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/social/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/social/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/social/languages","stargazers_url":"https://api.github.com/repos/OCA/social/stargazers","contributors_url":"https://api.github.com/repos/OCA/social/contributors","subscribers_url":"https://api.github.com/repos/OCA/social/subscribers","subscription_url":"https://api.github.com/repos/OCA/social/subscription","commits_url":"https://api.github.com/repos/OCA/social/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/social/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/social/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/social/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/social/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/social/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/social/merges","archive_url":"https://api.github.com/repos/OCA/social/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/social/downloads","issues_url":"https://api.github.com/repos/OCA/social/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/social/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/social/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/social/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/social/labels{/name}","releases_url":"https://api.github.com/repos/OCA/social/releases{/id}","created_at":"2015-07-13T12:06:47Z","updated_at":"2015-08-16T16:01:53Z","pushed_at":"2015-11-20T13:40:59Z","git_url":"git://github.com/OCA/social.git","ssh_url":"git@github.com:OCA/social.git","clone_url":"https://github.com/OCA/social.git","svn_url":"https://github.com/OCA/social","homepage":null,"size":492,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":7,"forks":19,"open_issues":7,"watchers":4,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/social/pulls/22"},"html":{"href":"https://github.com/OCA/social/pull/22"},"issue":{"href":"https://api.github.com/repos/OCA/social/issues/22"},"comments":{"href":"https://api.github.com/repos/OCA/social/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/social/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/social/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/social/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/social/statuses/44f2b93249b58566809b74b46be591f0d4515f6c"}}}}