allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 05/06: [#8323] Fix notification task calls by using .post method
Date Tue, 27 Aug 2019 15:37:53 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 176d299271e9ff6cfc7879db49449eafeb4a29f0
Author: Shalitha Suranga <shalithasuranga@gmail.com>
AuthorDate: Sat Aug 17 21:15:45 2019 +0530

    [#8323] Fix notification task calls by using .post method
---
 Allura/allura/controllers/discuss.py      | 4 ++--
 Allura/allura/controllers/repository.py   | 4 ++--
 Allura/allura/tasks/notification_tasks.py | 3 ++-
 ForgeBlog/forgeblog/main.py               | 4 ++--
 ForgeTracker/forgetracker/tracker_main.py | 4 ++--
 ForgeWiki/forgewiki/wiki_main.py          | 4 ++--
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index d3519c1..69ea86e 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -273,7 +273,7 @@ def handle_post_or_reply(thread, edit_widget, rate_limit, kw, parent_post_id=Non
     if thread.artifact:
         thread.artifact.mod_date = datetime.utcnow()
     flash('Message posted')
-    notification_tasks.send_usermentions_notification(p, kw['text'])
+    notification_tasks.send_usermentions_notification.post(p.index_id(), kw['text'])
     redirect(request.referer or '/')
 
 
@@ -327,7 +327,7 @@ class PostController(BaseController):
             self.post.last_edit_by_id = c.user._id
             self.thread.is_spam(self.post)  # run spam checker, nothing to do with result
yet
             self.post.commit()
-            notification_tasks.send_usermentions_notification(self.post, kw['text'], old_text)
+            notification_tasks.send_usermentions_notification.post(self.post.index_id(),
kw['text'], old_text)
             g.director.create_activity(c.user, 'modified', self.post,
                                        target=self.post.thread.artifact or self.post.thread,
                                        related_nodes=[self.post.app_config.project],
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 3d72882..783af70 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -220,7 +220,7 @@ class RepoRootController(BaseController, FeedController):
                 ref_id=mr.index_id(),
             )
             session(t).flush()
-            allura.tasks.notification_tasks.send_usermentions_notification(mr, kw['description'])
+            allura.tasks.notification_tasks.send_usermentions_notification.post(mr.index_id(),
kw['description'])
             g.director.create_activity(c.user, 'created', mr,
                                        related_nodes=[c.project], tags=['merge-request'])
             redirect(mr.url())
@@ -495,7 +495,7 @@ class MergeRequestController(object):
 
         if changes:
             self.req.add_meta_post(changes=changes)
-            allura.tasks.notification_tasks.send_usermentions_notification(self.req, kw['description'],
old_text)
+            allura.tasks.notification_tasks.send_usermentions_notification.post(self.req.index_id(),
kw['description'], old_text)
             g.director.create_activity(c.user, 'updated', self.req,
                                        related_nodes=[c.project], tags=['merge-request'])
         self.refresh()
diff --git a/Allura/allura/tasks/notification_tasks.py b/Allura/allura/tasks/notification_tasks.py
index e5280b6..f82063d 100644
--- a/Allura/allura/tasks/notification_tasks.py
+++ b/Allura/allura/tasks/notification_tasks.py
@@ -26,8 +26,9 @@ def notify(n_id, ref_ids, topic):
     M.Mailbox.fire_ready()
 
 @task
-def send_usermentions_notification(artifact, text, old_text=None):
+def send_usermentions_notification(artifact_id, text, old_text=None):
     from allura import model as M
+    artifact = M.ArtifactReference.query.get(_id=artifact_id).artifact
     usernames = utils.get_usernames_from_md(text)
     if old_text:
         old_usernames = utils.get_usernames_from_md(old_text)
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index be0a469..179340b 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -316,7 +316,7 @@ class RootController(BaseController, FeedController):
                              user=c.user, content_type='blog-post')
         if attachment is not None:
             post.add_multiple_attachments(attachment)
-        notification_tasks.send_usermentions_notification(post, kw['text'])
+        notification_tasks.send_usermentions_notification.post(post.index_id(), kw['text'])
         redirect(h.really_unicode(post.url()).encode('utf-8'))
 
     @with_trailing_slash
@@ -435,7 +435,7 @@ class PostController(BaseController, FeedController):
         for k, v in kw.iteritems():
             setattr(self.post, k, v)
         self.post.commit()
-        notification_tasks.send_usermentions_notification(self.post, kw['text'], old_text)
+        notification_tasks.send_usermentions_notification.post(self.post.index_id(), kw['text'],
old_text)
         redirect('.')
 
     @without_trailing_slash
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 1ff9dea..f4861a8 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -941,7 +941,7 @@ class RootController(BaseController, FeedController):
         g.spam_checker.check(ticket_form['summary'] + u'\n' + ticket_form.get('description',
''), artifact=ticket,
                              user=c.user, content_type='ticket')
         c.app.globals.invalidate_bin_counts()
-        notification_tasks.send_usermentions_notification(ticket, ticket_form.get('description',
''))
+        notification_tasks.send_usermentions_notification.post(ticket.index_id(), ticket_form.get('description',
''))
         g.director.create_activity(c.user, 'created', ticket,
                                    related_nodes=[c.project], tags=['ticket'])
         redirect(str(ticket.ticket_num) + '/')
@@ -1548,7 +1548,7 @@ class TicketController(BaseController, FeedController):
         self.ticket.commit()
         if comment:
             thread.post(text=comment, notify=False)
-        notification_tasks.send_usermentions_notification(self.ticket, new_text, old_text)
+        notification_tasks.send_usermentions_notification.post(self.ticket.index_id(), new_text,
old_text)
         g.director.create_activity(c.user, 'modified', self.ticket,
                                    related_nodes=[c.project], tags=['ticket'])
         c.app.globals.invalidate_bin_counts()
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 0032ea2..f0f2030 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -756,9 +756,9 @@ class PageController(BaseController, FeedController):
         g.spam_checker.check(title + u'\n' + text, artifact=self.page,
                              user=c.user, content_type='wiki')
         if activity_verb == 'created':
-            notification_tasks.send_usermentions_notification(self.page, text)
+            notification_tasks.send_usermentions_notification.post(self.page.index_id(),
text)
         elif activity_verb == 'modified':
-            notification_tasks.send_usermentions_notification(self.page, text, old_text)
+            notification_tasks.send_usermentions_notification.post(self.page.index_id(),
text, old_text)
         g.director.create_activity(c.user, activity_verb, self.page,
                                    related_nodes=[c.project], tags=['wiki'])
         if new_viewable_by:


Mime
View raw message