On 08/16/2016 12:02 AM, Joseph Myers wrote: > On Mon, 15 Aug 2016, Martin Liška wrote: > >> It can, currently we mark as spam just the first comment. If there's a spam >> PR >> which contains multiple comments, I'll extend the script. > > There certainly are spam bugs where the spammer pasted their spam in a > comment after creating the bug, rather than putting it in the initial bug > description; see bug 76607, for example. Maybe all comments created by > the original bug submitter should be considered as spam, not just the > initial bug description? >
Hi. Looks the bug has been already removed (which is good). Script improvement does exactly what Joseph suggested. If there's no objection, I'll commit it tomorrow. Martin
>From 98309a80a08b1d9e5f51c1e28f35322aaca8a52c Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Tue, 16 Aug 2016 14:14:07 +0200 Subject: [PATCH] mark_spam.py: Mark as spam all comments done by a creator contrib/ChangeLog: 2016-08-16 Martin Liska <mli...@suse.cz> * mark_spam.py: Mark as spam all comments done by a creator. --- contrib/mark_spam.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/contrib/mark_spam.py b/contrib/mark_spam.py index f206356..86f46a1 100755 --- a/contrib/mark_spam.py +++ b/contrib/mark_spam.py @@ -39,7 +39,9 @@ def mark_as_spam(id, api_key, verbose): return # 2) mark the bug as spam - cc_list = response['bugs'][0]['cc'] + bug = response['bugs'][0] + creator = bug['creator'] + cc_list = bug['cc'] data = { 'status': 'RESOLVED', 'resolution': 'INVALID', @@ -64,13 +66,15 @@ def mark_as_spam(id, api_key, verbose): # 3) mark the first comment as spam r = requests.get(u + '/comment') response = json.loads(r.text) - comment_id = response['bugs'][str(id)]['comments'][0]['id'] - - u2 = '%sbug/comment/%d/tags' % (base_url, comment_id) - r = requests.put(u2, json = {'comment_id': comment_id, 'add': ['spam'], 'api_key': api_key}) - if verbose: - print(r) - print(r.text) + for c in response['bugs'][str(id)]['comments']: + if c['creator'] == creator: + comment_id = c['id'] + u2 = '%sbug/comment/%d/tags' % (base_url, comment_id) + print(u2) + r = requests.put(u2, json = {'comment_id': comment_id, 'add': ['spam'], 'api_key': api_key}) + if verbose: + print(r) + print(r.text) # 4) mark all attachments as spam r = requests.get(u + '/attachment') -- 2.9.2