diff options
author | David Lawrence <dkl@mozilla.com> | 2015-05-11 16:36:15 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-05-11 16:36:15 +0200 |
commit | f805627ee9fcffba9f5a509bba652bfd663c6ae7 (patch) | |
tree | 9d2b335d577c461fd815b6bf90c035b17a4df3aa /Bugzilla | |
parent | e4362dad68b2b9180de14d7683d7645e17206f53 (diff) | |
download | bugzilla-f805627ee9fcffba9f5a509bba652bfd663c6ae7.tar.gz bugzilla-f805627ee9fcffba9f5a509bba652bfd663c6ae7.tar.xz |
Bug 1140575: Comment-creation WebService API should allow tags to be specified
r=glob,a=glob
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/API/1_0/Resource/Bug.pm | 5 | ||||
-rw-r--r-- | Bugzilla/Bug.pm | 24 |
2 files changed, 27 insertions, 2 deletions
diff --git a/Bugzilla/API/1_0/Resource/Bug.pm b/Bugzilla/API/1_0/Resource/Bug.pm index c0be3c730..6a32a687f 100644 --- a/Bugzilla/API/1_0/Resource/Bug.pm +++ b/Bugzilla/API/1_0/Resource/Bug.pm @@ -1154,6 +1154,11 @@ sub add_comment { $bug->add_comment($comment, { isprivate => $params->{is_private}, is_markdown => $params->{is_markdown}, work_time => $params->{work_time} }); + + # Add comment tags + $bug->set_all({ comment_tags => $params->{comment_tags} }) + if defined $params->{comment_tags}; + $bug->update(); my $new_comment_id = $bug->{added_comments}[0]->id; diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 6fcf14c5a..f24f7a4d2 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -720,6 +720,7 @@ sub create { my $creation_comment = delete $params->{comment}; my $is_markdown = delete $params->{is_markdown}; my $see_also = delete $params->{see_also}; + my $comment_tags = delete $params->{comment_tags}; # We don't want the bug to appear in the system until it's correctly # protected by groups. @@ -810,7 +811,16 @@ sub create { # Insert the comment. We always insert a comment on bug creation, # but sometimes it's blank. - Bugzilla::Comment->insert_create_data($creation_comment); + my $comment = Bugzilla::Comment->insert_create_data($creation_comment); + + # Add comment tags + if (defined $comment_tags && Bugzilla->user->can_tag_comments) { + $comment_tags = ref $comment_tags ? $comment_tags : [ $comment_tags ]; + foreach my $tag (@{$comment_tags}) { + $comment->add_tag($tag) if defined $tag; + } + $comment->update(); + } # Set up aliases my $sth_aliases = $dbh->prepare('INSERT INTO bugs_aliases (alias, bug_id) VALUES (?, ?)'); @@ -1039,7 +1049,7 @@ sub update { join(', ', @added_names)]; } - # Comments + # Comments and comment tags foreach my $comment (@{$self->{added_comments} || []}) { # Override the Comment's timestamp to be identical to the update # timestamp. @@ -1049,6 +1059,10 @@ sub update { LogActivityEntry($self->id, "work_time", "", $comment->work_time, $user->id, $delta_ts); } + foreach my $tag (@{$self->{added_comment_tags} || []}) { + $comment->add_tag($tag) if defined $tag; + } + $comment->update() if @{$self->{added_comment_tags} || []}; } # Comment Privacy @@ -2459,6 +2473,12 @@ sub set_all { is_markdown => $params->{'comment'}->{'is_markdown'} }); } + if (defined $params->{comment_tags} && Bugzilla->user->can_tag_comments()) { + $self->{added_comment_tags} = ref $params->{comment_tags} + ? $params->{comment_tags} + : [ $params->{comment_tags} ]; + } + if (exists $params->{alias} && $params->{alias}{set}) { $params->{alias} = { add => $params->{alias}{set}, |