Skip to content

Commit a62e029

Browse files
committed
After feedback from the RFC-Editor staff, changed the URL POST notification of Group name changes to an Email notification.
- Legacy-Id: 16210
1 parent b34b51c commit a62e029

3 files changed

Lines changed: 50 additions & 34 deletions

File tree

ietf/group/models.py

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33

44
import datetime
55
import email.utils
6-
import json
76
import jsonfield
87
import os
98
import re
10-
import requests
119

12-
from jwcrypto import jwk, jws
13-
from jwcrypto.common import json_encode
1410
from urlparse import urljoin
1511

1612
from django.conf import settings
@@ -26,7 +22,7 @@
2622
from ietf.group.colors import fg_group_colors, bg_group_colors
2723
from ietf.name.models import GroupStateName, GroupTypeName, DocTagName, GroupMilestoneStateName, RoleName, AgendaTypeName
2824
from ietf.person.models import Email, Person
29-
from ietf.utils.mail import formataddr
25+
from ietf.utils.mail import formataddr, send_mail_text
3026
from ietf.utils import log
3127
from ietf.utils.models import ForeignKey, OneToOneField
3228

@@ -367,31 +363,50 @@ def notify_rfceditor_of_group_name_change(sender, instance=None, **kwargs):
367363
current = Group.objects.get(pk=instance.pk)
368364
except Group.DoesNotExist:
369365
return
370-
url = settings.RFC_EDITOR_GROUP_NOTIFICATION_URL
371-
if url and instance.name != current.name:
372-
data = {
373-
'acronym': current.acronym,
374-
'old_name': current.name,
375-
'name': instance.name,
376-
}
377-
# Build signed data
378-
key = jwk.JWK()
379-
key.import_from_pem(settings.API_PRIVATE_KEY_PEM)
380-
payload = json.dumps(data)
381-
jwstoken = jws.JWS(payload.encode('utf-8'))
382-
jwstoken.add_signature(key, None,
383-
json_encode({"alg": settings.API_KEY_TYPE}),
384-
json_encode({"kid": key.thumbprint()}))
385-
sig = jwstoken.serialize()
386-
# Send signed data
387-
response = requests.post(url, data = { 'jws': sig, })
388-
log.log("Sent notify: %s: '%s' --> '%s' to %s, result code %s" %
389-
(current.acronym, current.name, instance.name, url, response.status_code))
390-
# Verify locally, to make sure we've got things right
391-
key = jwk.JWK()
392-
key.import_from_pem(settings.API_PUBLIC_KEY_PEM)
393-
jwstoken = jws.JWS()
394-
jwstoken.deserialize(sig)
395-
jwstoken.verify(key)
396-
log.assertion('payload == jwstoken.payload')
366+
addr = settings.RFC_EDITOR_GROUP_NOTIFICATION_EMAIL
367+
if addr and instance.name != current.name:
368+
msg = """
369+
This is an automated notification of a group name change:
370+
371+
acronym: %s
372+
old name: %s
373+
new name: %s
374+
375+
Regards,
376+
377+
The datatracker
378+
""" % (current.acronym, current.name, instance.name, )
379+
send_mail_text(None, to=addr, frm=None, subject="Group '%s' name change"%instance.acronym, txt=msg)
380+
log.log("Sent notification email: %s: '%s' --> '%s' to %s" % (current.acronym, current.name, instance.name, addr))
381+
382+
383+
## Keep this code as a worked and tested example of sending signed notifies
384+
## by HTTP POST. (superseded for this use case by email notification)
385+
# url = settings.RFC_EDITOR_GROUP_NOTIFICATION_URL
386+
# if url and instance.name != current.name:
387+
# data = {
388+
# 'acronym': current.acronym,
389+
# 'old_name': current.name,
390+
# 'name': instance.name,
391+
# }
392+
# # Build signed data
393+
# key = jwk.JWK()
394+
# key.import_from_pem(settings.API_PRIVATE_KEY_PEM)
395+
# payload = json.dumps(data)
396+
# jwstoken = jws.JWS(payload.encode('utf-8'))
397+
# jwstoken.add_signature(key, None,
398+
# json_encode({"alg": settings.API_KEY_TYPE}),
399+
# json_encode({"kid": key.thumbprint()}))
400+
# sig = jwstoken.serialize()
401+
# # Send signed data
402+
# response = requests.post(url, data = { 'jws': sig, })
403+
# log.log("Sent notify: %s: '%s' --> '%s' to %s, result code %s" %
404+
# (current.acronym, current.name, instance.name, url, response.status_code))
405+
# # Verify locally, to make sure we've got things right
406+
# key = jwk.JWK()
407+
# key.import_from_pem(settings.API_PUBLIC_KEY_PEM)
408+
# jwstoken = jws.JWS()
409+
# jwstoken.deserialize(sig)
410+
# jwstoken.verify(key)
411+
# log.assertion('payload == jwstoken.payload')
397412

ietf/group/tests_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def test_edit_info(self):
618618
self.assertEqual(group.groupurl_set.all()[0].url, "http://mars.mars")
619619
self.assertEqual(group.groupurl_set.all()[0].name, "MARS site")
620620
self.assertTrue(os.path.exists(os.path.join(self.charter_dir, "%s-%s.txt" % (group.charter.canonical_name(), group.charter.rev))))
621-
self.assertEqual(len(outbox), 1)
621+
self.assertEqual(len(outbox), 2)
622622
self.assertTrue('Personnel change' in outbox[0]['Subject'])
623623
for prefix in ['ad1','ad2','aread','marschairman','marsdelegate']:
624624
self.assertTrue(prefix+'@' in outbox[0]['To'])

ietf/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ def skip_unreadable_post(record):
704704

705705
RFC_EDITOR_SYNC_PASSWORD="secret"
706706
RFC_EDITOR_SYNC_NOTIFICATION_URL = "https://www.rfc-editor.org/parser/parser.php"
707-
RFC_EDITOR_GROUP_NOTIFICATION_URL = "https://www.rfc-editor.org/notification/group.php"
707+
RFC_EDITOR_GROUP_NOTIFICATION_EMAIL = "webmaster@rfc-editor.org"
708+
#RFC_EDITOR_GROUP_NOTIFICATION_URL = "https://www.rfc-editor.org/notification/group.php"
708709
RFC_EDITOR_QUEUE_URL = "https://www.rfc-editor.org/queue2.xml"
709710
RFC_EDITOR_INDEX_URL = "https://www.rfc-editor.org/rfc/rfc-index.xml"
710711
RFC_EDITOR_ERRATA_URL = "https://www.rfc-editor.org/errata_search.php?rfc={rfc_number}&rec_status=0"

0 commit comments

Comments
 (0)