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

Notify users mentioned in chat messages #460

Merged
merged 9 commits into from
Nov 21, 2017

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Nov 2, 2017

This pull request adds notifications for users mentioned in a chat; the notification links to the Talk room, and includes an ellipsized version of the original message centered around the mention (as the length of the notification message can be at most 64 bytes).

The rich subject of the notifications use call instead of room or chat due to call being already available in lib/public/RichObjectStrings/Definitions.php (in Nextcloud server). Unlike with the current code for invitation notifications, no checks are made on whether call is available or not, as the chat will be available only from Nextcloud 13 and onwards (I think so :-P ).

A mentioned user is notified only if she is able to participate in the room in which she was mentioned, that is, if she is already a participant of the room if the message was written in a private chat (a one to one chat, a group chat, or a password protected public chat), or in any case if the message was written in a public chat. When a room is deleted all the pending notifications for that room are also removed.

Still missing is not sending a notification to a user when she is mentioned in the chat room in which she is currently active. It is related to #459, but I will need some guidance here @nickvergessen @Ivansss (and if you want to implement it yourselves please feel free to do it ;-) ).

Finally, there are no integration tests yet, although they can be added at a later time.

@danxuliu danxuliu added this to the 3.0 (Nextcloud 13) milestone Nov 2, 2017
@danxuliu danxuliu mentioned this pull request Nov 2, 2017
7 tasks
* has no password, or if it has a password and the user is a participant
* already.
+
+ @param string userId
Copy link
Member

Choose a reason for hiding this comment

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

Somethign is wrong here

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@nickvergessen
Copy link
Member

Btw when is the PR for the chat UI coming? We need to merge stuff today............

@nickvergessen
Copy link
Member

I can take care of the notifications afterwards especially about the "hide when you are active"

@danxuliu danxuliu force-pushed the notify-users-mentioned-in-chat-messages branch from 7bafac4 to 59f7687 Compare November 2, 2017 10:58
@danxuliu
Copy link
Member Author

danxuliu commented Nov 2, 2017

Btw when is the PR for the chat UI coming? We need to merge stuff today............

Today? :-S I thought the limit was tomorrow... Well, then the PR for the chat UI will have to come today.

I can take care of the notifications afterwards especially about the "hide when you are active"

Great, thanks!

@nickvergessen nickvergessen modified the milestones: 3.0 (Nextcloud 13), 3.1 (Nextcloud 13.0.1/2) Nov 2, 2017
@nickvergessen nickvergessen self-assigned this Nov 16, 2017
@blizzz blizzz self-requested a review November 16, 2017 14:06
@nickvergessen nickvergessen force-pushed the notify-users-mentioned-in-chat-messages branch from 59f7687 to bef6d2a Compare November 17, 2017 10:04
@nickvergessen
Copy link
Member

While rebasing and looking into the stuff, I stumbled over a few things:

  1. I would not notify users when they not part of a public call. I can see a use case for that (like dragging them in), but I'd say, when you are not part of a room, you can not be mentioned.
  2. I would kill mentions of deleted users (they are mostlikely of no use anymore)

@nickvergessen
Copy link
Member

With the last commit I resolved 1. and also the issue with "dont mention while active"

@danxuliu
Copy link
Member Author

I would not notify users when they not part of a public call. I can see a use case for that (like dragging them in), but I'd say, when you are not part of a room, you can not be mentioned.

Well, I think that users should be notified when mentioned on a public room that they are not part of (that is why I made it that way :-P ). But I do not have a strong opinion on that, and you already removed it... :-P

I would kill mentions of deleted users (they are mostlikely of no use anymore)

I kept mentions by deleted users just for consistency with the Comments app. Anyway I do not have a strong opinion on this either, so feel free to drop them if you want.

With the last commit I resolved 1. and also the issue with "dont mention while active"

I have been thinking about not notifying a user when she is active and I am not sure about it. If a user is mentioned in an inactive room she will get a notification because she did not read the mention. I think that if a user is mentioned in an active room she should get the notification too until she actually read the mention.

It would be good if Talk could intercept the Notification app of its own tab/window to prevent it from showing notifications for chat mentions (just prevent it from showing, without discarding them). This would make possible to provide notifications better integrated with the Talk UI (for example, by adding a mention counter to the room in the room list) while not interfering with other open Nextcloud tabs/windows. @nickvergessen Is there any kind of support for that in the Notifications app?

Anyway, yes, currently if a user is active in a room she will immediately receive the messages, and thus the notification for the mention will be removed, because there is no support yet in the frontend nor the backend for unread messages. But I am working on that :-)

@nickvergessen
Copy link
Member

Just to clarify, because there seem to be a misunderstanding:
Users still get notifications for mentions in channels they are not active in. "Dont mention while active" was meant to be limited to the room. So you dont get a notification when you are mentioned in the verify same room. If you are in room A and a user in room B mentions you: 🔔
If you are in room A and a user in room A mentions you: 🔕

@danxuliu
Copy link
Member Author

Just to clarify, because there seem to be a misunderstanding:
If you are in room A and a user in room A mentions you: 🔕

No, that is exactly what I think that should not be done. I mean, if you are in room A and a user in room A mentions you you should be notified like in the other cases; only once you actually read the mention the notification should be removed.

An example:
-User joins a call in room A and hides the chat
-User is mentioned in the chat of room A, but she does not read it because the chat is hidden
-User ends the call and closes her browser without checking again the chat

In that scenario the user should have been notified about the mention even if she was active in the room.

@nickvergessen
Copy link
Member

The problem with this solution is, that you still get a push notification etc. So even though its immediatelly invalidated, you get noise.

danxuliu and others added 6 commits November 20, 2017 10:38
When a user is mentioned in a chat message she will now receive a
notification about that. If a chat room is deleted all the pending
notifications will be also removed.

The rich subject of the notifications use "call" instead of "room" or
"chat" due to "call" being already available in
"lib/public/RichObjectStrings/Definitions.php" (in Nextcloud server),
although the Notifications app does not handle it in any special way
though ("apps/notifications/js/richObjectStringParser.js").

Note that, unlike with the current code for invitation notifications, no
checks are made on whether "call" is available or not, as the chat is
available only from Nextcloud 13 and onwards.

Currently every user mentioned in a chat message is notified, but this
will be tightened in later commits (for example, if a user is mentioned
in a chat room to which she is not able to join).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The chat message can be much longer than the maximum length allowed for
notification messages, so the notification message is trimmed if needed.

When the notification is being prepared to be displayed it is taken into
account if the message was trimmed, and in that case an ellipsis is
added at the start and/or the end (depending on the case) of the
message.

Note that the original notification message does not contain the
ellipsis characters, as depending on the language a whitespace should be
added or not before and after an ellipsis, and the language in which the
notification will be displayed is only known at the time of displaying
it, but not when it is saved.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Now mentioned users are notified only if they are already participants
of a private chat (a one to one chat, a group chat, or a password
protected public chat), or if the message was written in a public chat.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Also removes notifications for public rooms where the user was not invited.

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the notify-users-mentioned-in-chat-messages branch from e615d17 to 18a9456 Compare November 20, 2017 09:38
@nickvergessen
Copy link
Member

Implemented this way now.

Also marking mention notifications read when you pull the messages of that room now.

…ad the chat

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the notify-users-mentioned-in-chat-messages branch from 18a9456 to 6346c5a Compare November 20, 2017 11:09
…ages of the room

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member

@Ivansss @danxuliu please review until tomorrow, so I can release it before our call.

Copy link
Member

@Ivansss Ivansss left a comment

Choose a reason for hiding this comment

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

Tested and works 👍
Push notifications are always sent though.

@nickvergessen nickvergessen merged commit b8a583d into master Nov 21, 2017
@nickvergessen nickvergessen deleted the notify-users-mentioned-in-chat-messages branch November 21, 2017 10:33
marcoambrosini pushed a commit that referenced this pull request Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants