-
Notifications
You must be signed in to change notification settings - Fork 438
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
Mentions PoC #9279
base: main
Are you sure you want to change the base?
Mentions PoC #9279
Conversation
|
||
@staticmethod | ||
def _parse_userids(text: str) -> list[str]: | ||
return USERID_PAT.findall(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll probably want to parse userids from text_rendered
html.
h/services/mention.py
Outdated
import re | ||
from typing import Iterable, Sequence | ||
|
||
import sqlalchemy as sa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't be shy about importing anything from sqlalchemy. I mean speling the whole from sqlalchemy import select, ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, is this the recommended way?
h/migrations/versions/022ea4bf4a27_update_mention_to_reference_annotation.py
Show resolved
Hide resolved
return [notification.mentioned_user.email], subject, text, html | ||
|
||
|
||
def _get_user_url(user, request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from emails/reply_notifcation.py
for now
return [] | ||
|
||
notifications = [] | ||
for mention in annotation.mentions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to factor in groups / permissions / limits here as well to avoid sending notifications when not appropriate.
h/presenters/mention_json.py
Outdated
"userid": self._mention.annotation.userid, | ||
"username": self._mention.user.username, | ||
"display_name": self._mention.user.display_name, | ||
"link": self._mention.user.uri, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can any of these be None
? (Other than the display_name
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question
uri
can also apparently be false at least in the db, not sure when it makes sense but still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it actually makes sense. We will not want to link users in the LMS context, for example.
def asdict(self) -> dict[str, Any]: | ||
return { | ||
"userid": self._mention.user.userid, | ||
"username": self._mention.user.username, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hypothesis/client#6787 (comment), we were discussing that perhaps we don't need to expose the username here, is it can be extracted from the userid.
I don't have a strong opinion though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be coming from the mention itself like this. It seems better to just store the info from the get go, especially considering the work Marcos has done on user renames already.
So we'll be storing the username at the time of mention on the mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. This is the username the user had at the time the mention was created, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's missing from the PoC due to some back-and-forth going at the time. Sorry for the confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Refs #9281
Adds
@mentions
support in the API, emails will be addressed separately.All of create / get / edit / search endpoints now support them.
Testing API
make db
devdata_admin
and generate API token from http://localhost:5000/account/developercurl -X GET --location "http://localhost:5000/api/search" \ -H "Authorization: Bearer <token>"
Mentions will be returned here as well
Testing emails
Notifications are sent only on creation for now
h/mail
folder for incoming mail