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

Add special notifications for mentions #1846

Merged
merged 5 commits into from
Nov 28, 2023

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Nov 21, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Sets a special type of notification message for received messages mentioning the current user.

Motivation and context

Closes #1451

Screenshots / GIFs

Before After
image

Tests

  • Receive a message mentioning you in a room you have notifications enabled.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 11

Checklist

@jmartinesp jmartinesp requested a review from a team as a code owner November 21, 2023 14:51
@jmartinesp jmartinesp requested review from bmarty and removed request for a team November 21, 2023 14:51
@ElementBot
Copy link
Collaborator

ElementBot commented Nov 21, 2023

Warnings
⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L23 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L28 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L33 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L38 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L43 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L48 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

Generated by 🚫 dangerJS against 849ea05

Copy link
Contributor

github-actions bot commented Nov 21, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/Kq7swW

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (12b3196) 66.48% compared to head (849ea05) 66.48%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1846   +/-   ##
========================================
  Coverage    66.48%   66.48%           
========================================
  Files         1308     1308           
  Lines        33055    33058    +3     
  Branches      7083     7084    +1     
========================================
+ Hits         21976    21979    +3     
  Misses        7724     7724           
  Partials      3355     3355           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp marked this pull request as draft November 21, 2023 16:19
@jmartinesp jmartinesp force-pushed the feature/jme/special-notifications-for-mentions branch from 013f875 to a9d4bdb Compare November 23, 2023 07:47
@jmartinesp jmartinesp marked this pull request as ready for review November 23, 2023 07:49
@jmartinesp jmartinesp added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Nov 23, 2023
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Nov 23, 2023
@@ -83,6 +83,11 @@ class NotifiableEventResolver @Inject constructor(
return when (val content = this.content) {
is NotificationContent.MessageLike.RoomMessage -> {
val messageBody = descriptionFromMessageContent(content, senderDisplayName ?: content.senderId.value)
val notificationBody = if (hasMention) {
stringProvider.getString(R.string.notification_mentioned_you_body, messageBody)
Copy link
Member

Choose a reason for hiding this comment

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

The value of the string is:

  <string name="notification_mentioned_you_body">"%1$s mentioned you.
%2$s"</string>

so it seems like a parameter is missing here? The messageBody will be used for %1$s and it should be the sender. Can you double check please?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe you want to use notification_mentioned_you_fallback_body instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not anymore: https://github.com/vector-im/element-x-android/pull/1846/files#diff-ceb20f078550a897a919802d4b7635a8299f6ac1ef679aefba72e4c294954f2dR11.

notification_mentioned_you_fallback_body was removed for this same reason. We decided to change what the message looked like since it was too verbose.

Copy link
Member

Choose a reason for hiding this comment

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

OK, it's fine now. I do not know what happened with all those string values, and it does not worth investigate more about it. Thanks!

@jmartinesp jmartinesp force-pushed the feature/jme/special-notifications-for-mentions branch from e0b9035 to 36ca1b7 Compare November 24, 2023 09:10
@jmartinesp jmartinesp requested a review from bmarty November 27, 2023 06:58
@jmartinesp jmartinesp added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Nov 28, 2023
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Nov 28, 2023
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -83,6 +83,11 @@ class NotifiableEventResolver @Inject constructor(
return when (val content = this.content) {
is NotificationContent.MessageLike.RoomMessage -> {
val messageBody = descriptionFromMessageContent(content, senderDisplayName ?: content.senderId.value)
val notificationBody = if (hasMention) {
stringProvider.getString(R.string.notification_mentioned_you_body, messageBody)
Copy link
Member

Choose a reason for hiding this comment

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

OK, it's fine now. I do not know what happened with all those string values, and it does not worth investigate more about it. Thanks!

@@ -82,6 +82,11 @@ class NotifiableEventResolver @Inject constructor(
return when (val content = this.content) {
is NotificationContent.MessageLike.RoomMessage -> {
val messageBody = descriptionFromMessageContent(content, senderDisplayName ?: content.senderId.value)
val notificationBody = if (hasMention) {
stringProvider.getString(R.string.notification_mentioned_you_body, messageBody)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a test in NotifiableEventResolverTest to cover this case?

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jmartinesp jmartinesp merged commit 4de256b into develop Nov 28, 2023
15 checks passed
@jmartinesp jmartinesp deleted the feature/jme/special-notifications-for-mentions branch November 28, 2023 09:41
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.

Mentions: Push notifications display user mentions differently
3 participants