api: add send_email flag for comments api to allow commenting without email notification.

- fixes #5581
This commit is contained in:
Bartlomiej Wolynczyk 2020-01-20 20:30:57 +01:00
parent 66a5b46e5f
commit d8cfd57a83
3 changed files with 14 additions and 5 deletions

View file

@ -56,5 +56,6 @@ class TestGetMethod(object):
'request': '<RequiredType>',
'resolves_comment_id': '<Optional:None>',
'status': '<Optional:None>',
'userid': '<Optional:<OptionalAttr:apiuser>>'}]
'userid': '<Optional:<OptionalAttr:apiuser>>',
'send_email': '<Optional:True>'}]
assert_ok(id_, expected, given=response.body)

View file

@ -452,7 +452,7 @@ def comment_pull_request(
message=Optional(None), commit_id=Optional(None), status=Optional(None),
comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE),
resolves_comment_id=Optional(None), extra_recipients=Optional([]),
userid=Optional(OAttr('apiuser'))):
userid=Optional(OAttr('apiuser')), send_email=Optional(True)):
"""
Comment on the pull request specified with the `pullrequestid`,
in the |repo| specified by the `repoid`, and optionally change the
@ -483,6 +483,8 @@ def comment_pull_request(
:type extra_recipients: Optional(list)
:param userid: Comment on the pull request as this user
:type userid: Optional(str or int)
:param send_email: Define if this comment should also send email notification
:type send_email: Optional(bool)
Example output:
@ -527,6 +529,7 @@ def comment_pull_request(
comment_type = Optional.extract(comment_type)
resolves_comment_id = Optional.extract(resolves_comment_id)
extra_recipients = Optional.extract(extra_recipients)
send_email = Optional.extract(send_email, binary=True)
if not message and not status:
raise JSONRPCError(
@ -587,7 +590,8 @@ def comment_pull_request(
comment_type=comment_type,
resolves_comment_id=resolves_comment_id,
auth_user=auth_user,
extra_recipients=extra_recipients
extra_recipients=extra_recipients,
send_email=send_email
)
if allowed_to_change_status and status:

View file

@ -1551,7 +1551,7 @@ def comment_commit(
request, apiuser, repoid, commit_id, message, status=Optional(None),
comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE),
resolves_comment_id=Optional(None), extra_recipients=Optional([]),
userid=Optional(OAttr('apiuser'))):
userid=Optional(OAttr('apiuser')), send_email=Optional(True)):
"""
Set a commit comment, and optionally change the status of the commit.
@ -1575,6 +1575,8 @@ def comment_commit(
:type extra_recipients: Optional(list)
:param userid: Set the user name of the comment creator.
:type userid: Optional(str or int)
:param send_email: Define if this comment should also send email notification
:type send_email: Optional(bool)
Example error output:
@ -1610,6 +1612,7 @@ def comment_commit(
comment_type = Optional.extract(comment_type)
resolves_comment_id = Optional.extract(resolves_comment_id)
extra_recipients = Optional.extract(extra_recipients)
send_email = Optional.extract(send_email, binary=True)
allowed_statuses = [x[0] for x in ChangesetStatus.STATUSES]
if status and status not in allowed_statuses:
@ -1639,7 +1642,8 @@ def comment_commit(
comment_type=comment_type,
resolves_comment_id=resolves_comment_id,
auth_user=apiuser,
extra_recipients=extra_recipients
extra_recipients=extra_recipients,
send_email=send_email
)
if status:
# also do a status change