From 6b143e60892773eaeb728d078190bd6071af3525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Oct 2016 12:44:36 +0200 Subject: [PATCH] [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. --- addons/website_blog/models/website_blog.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py index 415e0355ac8..e2cec821a00 100644 --- a/addons/website_blog/models/website_blog.py +++ b/addons/website_blog/models/website_blog.py @@ -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