#3721 reporter and assignee headers added to notification emails
Merged 3 years ago by pingou. Opened 3 years ago by lenkaseg.

file modified
+63
@@ -286,6 +286,8 @@

      in_reply_to=None,

      project_name=None,

      user_from=None,

+     reporter=None,

+     assignee=None

  ):  # pragma: no cover

      """ Send an email with the specified information.

  
@@ -346,6 +348,10 @@

              msg["List-Archive"] = _build_url(

                  pagure_config["APP_URL"], _fullname_to_url(project_name)

              )

+         if reporter is not None:

+             msg["X-pagure-reporter"] = reporter

+         if assignee is not None:

+             msg["X-pagure-assignee"] = assignee

  

          # Send the message via our own SMTP server, but don't include the

          # envelope header.
@@ -445,6 +451,8 @@

      mail_to = _add_mentioned_users(mail_to, comment.comment)

      mail_to = _clean_emails(mail_to, user)

  

+     assignee = comment.issue.assignee.user if comment.issue.assignee else None

+ 

      send_email(

          text,

          "Issue #%s: %s" % (comment.issue.id, comment.issue.title),
@@ -453,6 +461,8 @@

          in_reply_to=comment.issue.mail_id,

          project_name=comment.issue.project.fullname,

          user_from=comment.user.fullname or comment.user.user,

+         reporter=comment.issue.user.user,

+         assignee=assignee

      )

  

  
@@ -484,6 +494,8 @@

      mail_to = _add_mentioned_users(mail_to, issue.content)

      mail_to = _clean_emails(mail_to, user)

  

+     assignee = issue.assignee.user if issue.assignee else None

+ 

      send_email(

          text,

          "Issue #%s: %s" % (issue.id, issue.title),
@@ -491,6 +503,8 @@

          mail_id=issue.mail_id,

          project_name=issue.project.fullname,

          user_from=issue.user.fullname or issue.user.user,

+         reporter=issue.user.user,

+         assignee=assignee

      )

  

  
@@ -523,6 +537,9 @@

      mail_to = _clean_emails(mail_to, user)

  

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = issue.assignee.user if issue.assignee else None

+ 

      send_email(

          text,

          "Issue #%s: %s" % (issue.id, issue.title),
@@ -531,6 +548,8 @@

          in_reply_to=issue.mail_id,

          project_name=issue.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=issue.user.user,

+         assignee=assignee

      )

  

  
@@ -559,6 +578,9 @@

      mail_to = _get_emails_for_obj(issue)

  

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = issue.assignee.user if issue.assignee else None

+ 

      send_email(

          text,

          "Issue #%s: %s" % (issue.id, issue.title),
@@ -567,6 +589,8 @@

          in_reply_to=issue.mail_id,

          project_name=issue.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=issue.user.user,

+         assignee=assignee

      )

  

  
@@ -591,6 +615,9 @@

      )

      mail_to = _get_emails_for_obj(issue)

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = issue.assignee.user if issue.assignee else None

+ 

      send_email(

          text,

          "Issue #%s: %s" % (issue.id, issue.title),
@@ -599,6 +626,8 @@

          in_reply_to=issue.mail_id,

          project_name=issue.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=issue.user.user,

+         assignee=assignee

      )

  

  
@@ -631,6 +660,9 @@

      mail_to = _clean_emails(mail_to, user)

  

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = request.assignee.user if request.assignee else None

+ 

      send_email(

          text,

          "PR #%s: %s" % (request.id, request.title),
@@ -639,6 +671,8 @@

          in_reply_to=request.mail_id,

          project_name=request.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=request.user.user,

+         assignee=assignee

      )

  

  
@@ -668,6 +702,8 @@

      )

      mail_to = _get_emails_for_obj(request)

  

+     assignee = request.assignee.user if request.assignee else None

+ 

      send_email(

          text,

          "PR #%s: %s" % (request.id, request.title),
@@ -675,6 +711,8 @@

          mail_id=request.mail_id,

          project_name=request.project.fullname,

          user_from=request.user.fullname or request.user.user,

+         reporter=request.user.user,

+         assignee=assignee

      )

  

  
@@ -706,6 +744,9 @@

      mail_to = _get_emails_for_obj(request)

  

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = request.assignee.user if request.assignee else None

+ 

      send_email(

          text,

          "PR #%s: %s" % (request.id, request.title),
@@ -714,6 +755,8 @@

          in_reply_to=request.mail_id,

          project_name=request.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=request.user.user,

+         assignee=assignee

      )

  

  
@@ -745,6 +788,9 @@

      mail_to = _get_emails_for_obj(request)

  

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = request.assignee.user if request.assignee else None

+ 

      send_email(

          text,

          "PR #%s: %s" % (request.id, request.title),
@@ -753,6 +799,8 @@

          in_reply_to=request.mail_id,

          project_name=request.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=request.user.user,

+         assignee=assignee

      )

  

  
@@ -784,6 +832,9 @@

      mail_to = _get_emails_for_obj(request)

  

      uid = time.mktime(datetime.datetime.now().timetuple())

+ 

+     assignee = request.assignee.user if request.assignee else None

+ 

      send_email(

          text,

          "PR #%s: %s" % (request.id, request.title),
@@ -792,6 +843,8 @@

          in_reply_to=request.mail_id,

          project_name=request.project.fullname,

          user_from=user.fullname or user.user,

+         reporter=request.user.user,

+         assignee=assignee

      )

  

  
@@ -823,6 +876,9 @@

      mail_to = _add_mentioned_users(mail_to, comment.comment)

      mail_to = _clean_emails(mail_to, user)

  

+     assignee = (comment.pull_request.assignee.user if

+                 comment.pull_request.assignee else None)

+ 

      send_email(

          text,

          "PR #%s: %s" % (comment.pull_request.id, comment.pull_request.title),
@@ -831,6 +887,8 @@

          in_reply_to=comment.pull_request.mail_id,

          project_name=comment.pull_request.project.fullname,

          user_from=comment.user.fullname or comment.user.user,

+         reporter=comment.pull_request.user.user,

+         assignee=assignee

      )

  

  
@@ -856,6 +914,9 @@

      )

      mail_to = _get_emails_for_obj(flag.pull_request)

  

+     assignee = (flag.pull_request.assignee.user if flag.pull_request.assignee

+                 else None)

+ 

      send_email(

          text,

          "PR #%s - %s: %s" % (flag.pull_request.id, flag.username, flag.status),
@@ -864,6 +925,8 @@

          in_reply_to=flag.pull_request.mail_id,

          project_name=flag.pull_request.project.fullname,

          user_from=flag.username,

+         reporter=flag.pull_request.user.user,

+         assignee=assignee

      )

  

  

@@ -501,6 +501,8 @@

              mail_id='test-pull-request-2edbf96ebe644f4bb31b94605e-1',

              in_reply_to='test-pull-request-2edbf96ebe644f4bb31b94605e',

              project_name='namespace/project',

+             reporter='reporter',

+             assignee='assignee',

              user_from='Zöé',

          )

          # Due to differences in the way Python2 and Python3 encode non-ascii
@@ -522,6 +524,8 @@

  X-pagure-project: namespace/project

  List-ID: namespace/project

  List-Archive: http://localhost.localdomain/namespace/project

+ X-pagure-reporter: reporter

+ X-pagure-assignee: assignee

  

  RW1haWwgY29udGVudA==

  '''

This will allow users to filter by their reported bugs and assigned bugs.

Fixes #3647

Change looks fine with two comments:

rebased onto 62bc32a93cc1e6a6174ebeed5081bbadfd8f0b5d

3 years ago

Do we have tests for this portion of functionality that should be updated to check for these new headers?

Would be nice to add some, I don't think the existing tests cover this

rebased onto 8521c5980e77a5af1326a3b15496b7795ba338ec

3 years ago

Looks good, let's rebase and get it in :)

rebased onto 9cb3f32

3 years ago

Pull-Request has been merged by pingou

3 years ago