Skip to content

Remove stream editor email duplication#10

Open
meadmaker wants to merge 11 commits intomainfrom
mark/remove_stream_editor_email_duplication
Open

Remove stream editor email duplication#10
meadmaker wants to merge 11 commits intomainfrom
mark/remove_stream_editor_email_duplication

Conversation

@meadmaker
Copy link
Copy Markdown

These changes will prevent the stream editor email address from being included in the Notice emails field during the creation of a conflict review. This only works for documents in the IRTF or ISE streams.

  • If the stream editor email address is detected in the input, then the address is silently removed.
  • The address is removed even if it has been entered multiple times.
  • The email address suggestion generator has been updated to remove the stream editors
  • The help text for the Notice emails field has been updated to say that the stream editors are automatically notified.

While I was in the code, I refactored a bit:

  • The SimpleStartReviewForm is now a superclass to the StartReviewForm. This was intended to ease the creation of a single clean_notify() validation method, which eventually moved to the view code instead. However, the refactoring was left.
  • The start_review_as_secretariat() and start_review_as_stream_owner() methods are now merged. Ironically, this resulted in the exact same number of lines of code, but at least there is only one method to update going forward.

Fixes ietf-tools#3638.

When I make changes to the notify field, now I only have to change it in one place.
The start_review_as_secretariat and start_review_as_stream_owner methods were virtually identical.  Consolidate them using a few conditional checks.  Now the logic isn't duplicated, so we won't need to perform maintenance in two places.
This will:
- Find the stream managers by calling Recipient.gather()
- extract just their email addresses
- Split the 'notify' field by commas
- Remove any item in the notifications list that matches any of the stream manager emails.

Yes, this will incorrectly remove email addresses like:
  "rfc-ise@rfc-editor.org"<other_addy@example.com>
Anyone who enters that gets what they deserve.
Because the document name isn't available to the form, so I can't retrieve the document in the form's `clean()` method, so I can't discover the correct document stream in the form.
I expect that this will always be satisfied, but it's a good assumption validation.
Copy link
Copy Markdown
Collaborator

@jennifer-richards jennifer-richards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a bunch of nit picky suggestions plus one real question.

Comment thread ietf/doc/tests_conflict_review.py Outdated
ad_strpk = str(Person.objects.get(name='Areað Irector').pk)
state_strpk = str(State.objects.get(used=True, slug='needshep', type__slug='conflrev').pk)
self.client.login(username="secretary", password="secretary+password")
""" This set of notification recipients should cover a bunch of cases for this test.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be a comment - triple quotes aren't meant for multiline comments, notwithstanding their use as a docstring after a function def.

Comment thread ietf/doc/tests_conflict_review.py Outdated

# Get the email addresses which should remain
other_emails = [manager_emails[stream]
for stream in list(manager_emails)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pythonic preference would be [mgr_email for stream, mgr_email in manage_emails.items() if..]. If you prefr as-is, you can drop the list. (A dict acts as an iterator over its keys.)

Comment thread ietf/doc/views_conflict_review.py Outdated
def start_review(request, name):
if has_role(request.user,"Secretariat"):
return start_review_as_secretariat(request,name)
"""Start the conflict review process, setting the initial
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring format should ideally be:

def somefunc():
    '''Do the thing this method does in a single line

    After a blank line, describe in more detail / document parameters, etc.
    '''

Comment thread ietf/doc/views_conflict_review.py Outdated

notify = cleaned_data['notify']
stream_managers = [
re.sub('([^<]*<)?(.*)(>.*)', '\2', r)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use email.utils.parseaddr() here - it'll return a tuple, (realname, email). If you apply that to addresses in the notifications list when filtering, I think that'd get rid of the caveat (although I 100% agree they get what they deserve if you choose to keep it simple)

Comment thread ietf/doc/views_conflict_review.py Outdated
if doc_to_review.stream.slug not in ['ise', 'irtf']:
notify_addresses.extend(
[r.formatted_email()
for r in Role.objects.filter(group__acronym=doc_to_review.stream.slug, name='chair')]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this match the addresses now being filtered out from the notify list? Here, it's addresses for 'chair' Roles. The filtered items are 'stream_managers' from Recipients. Do these match up in the right way?

Instead of avoiding adding document stream chair addresses as a currently accurate proxy for the stream editor addresses, use the gather_stream_managers() function to find the exact addresses to avoid and remove those from any address we consider.
@meadmaker
Copy link
Copy Markdown
Author

Back at ya!

@painless-security painless-security deleted a comment from bmgparts May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conflict Review request form should make it clear that the ise is already going to be copied

3 participants