Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6682] Add UserMessage feature for Institutional Access #10824

Conversation

Johnetordoff
Copy link
Contributor

@Johnetordoff Johnetordoff commented Dec 5, 2024

Purpose

This is to allow institutional admins limited messaging capabilities for users within their institution. This PR should allow an email message be sent to an institution member by an admin, using the UserMessage system.

Changes

  • adds UserMessagePermissions
  • adds UserMessage model with MessageType choices
  • adds unit tests
  • adds UserMessageView
  • adds UserMessageSerializer
  • adds is_institutional_admin method to user model
  • adds UserMessageFactory
  • adds USER_MESSAGE_INSTITUTIONAL_ACCESS_REQUEST email template

QA Notes

Please make verification statements inspired by your code and what your code touches.

  • Verify
  • Verify

What are the areas of risk?

Any concerns/considerations/questions that development raised?

Documentation

Side Effects

Ticket

https://openscience.atlassian.net/browse/ENG-6682

Bits discussed in at ARB:

#10841

@Johnetordoff Johnetordoff changed the title [ENG-6682] Add new UserMessage feature for Institutional Access [ENG-6682] Add UserMessage feature for Institutional Access Dec 5, 2024
},
)

def to_internal_value(self, data):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was caused by using the RelationshipField it doesn't handle POSTing to relationships well.

@Johnetordoff Johnetordoff force-pushed the institutional-access-user-message branch from ce125ed to f7a73c2 Compare December 5, 2024 19:40
@Johnetordoff Johnetordoff force-pushed the institutional-access-user-message branch from f7a73c2 to edb3118 Compare December 5, 2024 19:41
@Johnetordoff Johnetordoff marked this pull request as ready for review December 5, 2024 22:02
Copy link
Collaborator

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

A few changes requested. Also, I'm not seeing some of the things mentioned in ARB. For example, did you ask product have having a "cc the sender" option, or did they say no to that? I also didn't see any rate limiting on the API call. Please go over the list of suggestions from ARB and make sure that they're all either disapproved by Product or implemented here.

api/users/permissions.py Outdated Show resolved Hide resolved
Comment on lines 75 to 76
if message_type == MessageTypes.INSTITUTIONAL_REQUEST:
return self._validate_institutional_request(request, user)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the right place for this check? Again, it would give a 403, when a 409 Conflict or just a straight 400 might be more appropriate.

Copy link
Contributor Author

@Johnetordoff Johnetordoff Dec 6, 2024

Choose a reason for hiding this comment

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

Since currently this only applies to insti admin, I'll make that check here and move the institution validation and other details to the serializer. Good comment thanks.

api/users/permissions.py Outdated Show resolved Hide resolved
api/users/serializers.py Outdated Show resolved Hide resolved
api/users/serializers.py Outdated Show resolved Hide resolved
api/users/serializers.py Outdated Show resolved Hide resolved
osf/models/user_message.py Outdated Show resolved Hide resolved
Comment on lines 17 to 19
<p>
To review this request, please visit your project dashboard or contact your institution administrator for further details.
</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't accurate for this kind of email. Please check with product to verify what the text of the email surrounding the comment will be when it's not a request for access message. Also, the name of the email template is not correct for this feature, since it's not a request for access message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that I simply copied the wrong message Product gave me, here's their docs if you want to confirm scroll down to the end. https://docs.google.com/document/d/1ZVbfohipKiJrMeRQIp3xCIdO_l9kyMVPui1-CP0teBs/edit?tab=t.0

@Johnetordoff
Copy link
Contributor Author

@brianjgeiger For the thing mentioned in the ARB, I assumed that these would come after the the other aspects have been approved. I'd like to make the reply-to header and ccing sender a separate PR, because it's not MVP. I also need to do more research I'd like to confirm the Django stuff we know before we add a new feature that hasn't been tested before. But I'm open to putting it in this PR. I'd just like to isolate that functionality in a new PR after this, because I'm not too familiar with reply-to headers it and I want to include a testing suite which is a little scope creeping here.

@Johnetordoff
Copy link
Contributor Author

Maybe I can cc here, but reply-to in another PR?

@Johnetordoff Johnetordoff force-pushed the institutional-access-user-message branch from 9fc47ae to cd45df2 Compare December 6, 2024 22:07
@brianjgeiger
Copy link
Collaborator

Okay, that's fine.

@brianjgeiger
Copy link
Collaborator

@Johnetordoff The cc: functionality was only supposed to go to the sender. It was a way of giving the sender confirmation that the message was sent and what the contents of the message was. It was not meant to go to the other institutional admins at all.

@brianjgeiger
Copy link
Collaborator

Also, did you ask Product about the cc functionality, or did you just add it? I didn't see any questions in slack about any of the ARB ideas.

@Johnetordoff
Copy link
Contributor Author

Johnetordoff commented Dec 9, 2024

@brianjgeiger I spoke with Product and had a meeting with Blaine right after the ARB and she was enthusiastic about adding the reply-to and cc-ing features, agreed with the developers that they seemed like a good idea anyway. The "just message" for the Project tab they supported to and said that they would supoort any UI changes for that.

I'll try to keep some of this discussion in the slack. Sorry about that.

Copy link
Collaborator

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

Almost there. A couple more changes to views, and maybe another test.

Oh, also, could you make a feature/institutional_access branch and point this to that, rather than pointing it directly to develop?

Comment on lines 974 to 979
required_read_scopes = [CoreScopes.USERS_READ]
required_write_scopes = [CoreScopes.USERS_WRITE]
parser_classes = (JSONAPIMultipleRelationshipsParser, JSONAPIMultipleRelationshipsParserForRegularJSON)

serializer_class = UserMessageSerializer

Copy link
Collaborator

Choose a reason for hiding this comment

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

This view should have Throttle classes set per ARB. Probably just needs:

 throttle_classes = [BurstRateThrottle, SendEmailThrottle]

UserMessagePermissions,
)

required_read_scopes = [CoreScopes.USERS_READ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably needs USER_EMAIL_READ as well.

@Johnetordoff Johnetordoff changed the base branch from develop to feature/institutional_access December 10, 2024 15:15
@Johnetordoff Johnetordoff force-pushed the institutional-access-user-message branch from c91534e to f3ab16b Compare December 10, 2024 15:25
@Johnetordoff Johnetordoff merged commit 9831d86 into CenterForOpenScience:feature/institutional_access Dec 11, 2024
6 checks passed
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.

2 participants