diff options
author | Magnus Hagander | 2018-02-21 17:31:54 +0000 |
---|---|---|
committer | Magnus Hagander | 2018-02-21 17:45:19 +0000 |
commit | b8274b5875a4742800307ed645f1137c10e2a09d (patch) | |
tree | fd91a0b4b27e7f822c8bedfcf976c5662b152621 /pgcommitfest/commitfest/ajax.py | |
parent | da4c56069c8f61dd7e8f499827618e527e1a4a1b (diff) |
Implement thread notification receiving
This allows the archivs server to ping the CF app to pick up updates to
mailthreads quicker.
Diffstat (limited to 'pgcommitfest/commitfest/ajax.py')
-rw-r--r-- | pgcommitfest/commitfest/ajax.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pgcommitfest/commitfest/ajax.py b/pgcommitfest/commitfest/ajax.py index cffc33d..b65de8d 100644 --- a/pgcommitfest/commitfest/ajax.py +++ b/pgcommitfest/commitfest/ajax.py @@ -79,6 +79,22 @@ def getMessages(request): r = _archivesAPI('/message-id.json/%s' % thread.messageid) return sorted(r, key=lambda x: x['date'], reverse=True) +def refresh_single_thread(thread): + r = sorted(_archivesAPI('/message-id.json/%s' % thread.messageid), key=lambda x: x['date']) + if thread.latestmsgid != r[-1]['msgid']: + # There is now a newer mail in the thread! + thread.latestmsgid = r[-1]['msgid'] + thread.latestmessage = r[-1]['date'] + thread.latestauthor = r[-1]['from'] + thread.latestsubject = r[-1]['subj'] + thread.save() + parse_and_add_attachments(r, thread) + # Potentially update the last mail date - if there wasn't already a mail on each patch + # from a *different* thread that had an earlier date. + for p in thread.patches.filter(lastmail__lt=thread.latestmessage): + p.lastmail = thread.latestmessage + p.save() + @transaction.atomic def annotateMessage(request): thread = get_object_or_404(MailThread, pk=int(request.POST['t'])) |