From 053ab19ee3e1856c3b2d54f50b980d53ddec9a26 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 25 2019 08:22:39 +0000 Subject: Send a notification upon editing the initial comment of a PR We're sending notification when someone edits the initial comment of a PR. This notification can now be using any of the bus we support or simply web-hooks. Fixes https://pagure.io/pagure/issue/4398 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/api/fork.py b/pagure/api/fork.py index 9451f94..64eb542 100644 --- a/pagure/api/fork.py +++ b/pagure/api/fork.py @@ -491,6 +491,18 @@ def api_pull_request_update(repo, requestid, username=None, namespace=None): request.title = form.title.data.strip() request.initial_comment = form.initial_comment.data.strip() flask.g.session.add(request) + if not request.private and not request.project.private: + pagure.lib.notify.log( + request.project, + topic="pull-request.initial_comment.edited", + msg={ + "pullrequest": request.to_json( + public=True, with_comments=False + ), + "project": request.project.to_json(public=True), + "agent": flask.g.fas_user.username, + }, + ) try: # Link the PR to issue(s) if there is such link pagure.lib.query.link_pr_to_issue_on_description( diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index ef5b312..6262e20 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -538,6 +538,18 @@ def request_pull_edit(repo, requestid, username=None, namespace=None): request.title = form.title.data.strip() request.initial_comment = form.initial_comment.data.strip() flask.g.session.add(request) + if not request.private and not request.project.private: + pagure.lib.notify.log( + request.project, + topic="pull-request.initial_comment.edited", + msg={ + "pullrequest": request.to_json( + public=True, with_comments=False + ), + "project": request.project.to_json(public=True), + "agent": flask.g.fas_user.username, + }, + ) try: # Link the PR to issue(s) if there is such link pagure.lib.query.link_pr_to_issue_on_description(