[FIX] website_blog: handle replies to Blog Post Published as notes

As the Blog Post Published message is posted on a channel every reply
to this message is also posted on the blog. However blogs may holds
lot of followers not necessarily interested in being spammed by answers
to that message. We consider now that those replies are notes to avoid
spam. Blog managers can follow the note subtype to be warned about
those messages.
This commit is contained in:
Thibault Delavallée
2016-10-14 11:03:57 +02:00
parent f83e706786
commit 6b143e6089
+15 -1
View File
@@ -4,7 +4,7 @@ from datetime import datetime
import lxml
import random
from openerp import tools
from openerp import api, tools
from openerp import SUPERUSER_ID
from openerp.addons.website.models.website import slug
from openerp.osv import osv, fields
@@ -37,6 +37,20 @@ class Blog(osv.Model):
BlogPost.write(cr, uid, post_ids, {'active': vals['active']}, context=context)
return res
@api.multi
def message_post(self, parent_id=False, subtype=None, **kwargs):
""" Temporary workaround to avoid spam. If someone replies on a channel
through the 'Presentation Published' email, it should be considered as a
note as we don't want all channel followers to be notified of this answer. """
self.ensure_one()
if parent_id:
parent_message = self.env['mail.message'].sudo().browse(parent_id)
if parent_message.subtype_id and parent_message.subtype_id == self.env.ref('website_blog.mt_blog_blog_published'):
if kwargs.get('subtype_id'):
kwargs['subtype_id'] = False
subtype = 'mail.mt_note'
return super(Blog, self).message_post(parent_id=parent_id, subtype=subtype, **kwargs)
def all_tags(self, cr, uid, ids, min_limit=1, context=None):
req = """
SELECT