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

MM-55036 - Calls: Fix: Receiving in-app notifications for calls notifications while active #7623

Merged
merged 5 commits into from
Nov 16, 2023

Conversation

cpoile
Copy link
Member

@cpoile cpoile commented Oct 20, 2023

Summary

  • Fix for receiving in-app notifications for calls notifications while active -- we no longer see the overlay when the app is active
  • NOTE: we are testing on the exact message sent by the calls plugin.
    • This is not elegant, I agree. We could add a new NOTIFICATION_TYPE.CALLS (which would require changes across the products). That would certainly be more "correct." But on the other hand: the current solution won't break because there's no other way for the existing products to accidentally send those exact messages. The only way would be for the product or a plugin to explicitly send them, and if they do that then they could just as easily send a NOTIFICATION_TYPE.CALLS too.
    • We are now testing by pushnotification type, for push proxy v5.27.0 +
  • For iOS we keep the notification's buzz and alert sound. Android doesn't have this ability, so added a ticket to track: https://mattermost.atlassian.net/browse/MM-55059 (/cc @matthewbirtch)

Ticket Link

Checklist

  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Includes text changes and localization file updates
  • Have tested against the 5 core themes to ensure consistency between them.

Device Information

  • Android: 13, Pixel 6
  • Android: 13, Galaxy Tab s7+
  • iOS: 16.5.1, iPhone 14

Release Note

Calls: Fixed an issue where the in-app "push" notification overlay would appear when the user already received the incoming call notification banner.

@cpoile cpoile added the 2: Dev Review Requires review by a core commiter label Oct 20, 2023
@cpoile cpoile requested review from streamer45 and enahum October 20, 2023 18:10
Copy link
Contributor

@enahum enahum left a comment

Choose a reason for hiding this comment

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

Definitely not elengant but ok for the time being, I would definitely want us to go in the direction of the type of message in the near future, yes is more work but it does keep it cleaner and consistent even if we decide to chsnge the message.

My worry on this and perhaps cause idk the details, is, can the message of the notification be in a language different than english?

@cpoile
Copy link
Member Author

cpoile commented Oct 20, 2023

@enahum Yes, great point - we have a ticket for i18n to be completed for 1.0, so I've added ticket for typing the calls push notification: https://mattermost.atlassian.net/browse/MM-55060

@matthewbirtch matthewbirtch added the Build Apps for PR Build the mobile app for iOS and Android to test label Oct 20, 2023
@mattermost-build mattermost-build removed the Build Apps for PR Build the mobile app for iOS and Android to test label Oct 20, 2023
@mattermost-build
Copy link
Contributor

Building app in separate branch.

@streamer45
Copy link
Contributor

which would require changes across the products

Could you help me understand what it would take to do this cleanly?

@cpoile
Copy link
Member Author

cpoile commented Nov 9, 2023

@streamer45 An update: I'm working on it, but I'm hitting snags. We can chat in our 1:1.

@cpoile
Copy link
Member Author

cpoile commented Nov 10, 2023

Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

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

Thanks 💯

Comment on lines 156 to 158
export function isCallsStartedMessage(message = '') {
return (message === 'You\'ve been invited to a call' || callsMessageRegex.test(message));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we leave a comment to deprecate this at some point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 13d1946

@streamer45 streamer45 added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Nov 13, 2023
@cpoile
Copy link
Member Author

cpoile commented Nov 14, 2023

Please see: mattermost/mattermost#25405 (comment)
Changes here are from 2203aae
Thanks everyone.

@cpoile cpoile requested review from streamer45 and enahum November 14, 2023 19:10
@cpoile cpoile removed the 4: Reviews Complete All reviewers have approved the pull request label Nov 14, 2023
@cpoile cpoile added the 2: Dev Review Requires review by a core commiter label Nov 14, 2023
@@ -14,6 +15,8 @@ import type PostModel from '@typings/database/models/servers/post';
import type {IntlShape} from 'react-intl';
import type {RTCIceServer} from 'react-native-webrtc';

const callsMessageRegex = /^\u200b.* is inviting you to a call$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add a note here not to forget when the plugin starts to support localization

Copy link
Member Author

@cpoile cpoile Nov 15, 2023

Choose a reason for hiding this comment

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

This regex won't need to be changed when we support localization -- when we support localization it will be handled by the sub_type check. The regex will still be needed to match older messages from pre-0.21.0 calls (or pre-change MM server and pre-change proxy servers). When we finally remove that section of the code below, this can be removed (it will show up as dead-code and go will tell us).
Just in case, I added a note to the removal ticket https://mattermost.atlassian.net/browse/MM-55506

Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

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

Good stuff 👍

@cpoile cpoile added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Nov 16, 2023
@cpoile cpoile merged commit 6fb5d85 into main Nov 16, 2023
1 check passed
@cpoile cpoile deleted the MM-55036-fix-calls-in-app-notfication branch November 16, 2023 14:28
@amyblais amyblais added this to the v2.12.0 milestone Nov 16, 2023
fewva pushed a commit to fewva/mattermost-mobile that referenced this pull request Jan 12, 2024
…ications while active (mattermost#7623)

* when active, do not show overlay if this is a calls-started notification

* add calls notification type; keep message test for backwards compat

* process calls notifications properly

* revert NOTIFICATION_TYPE.CALLS; use sub_type for backwards compatibility

* add ticket and comment for future refactoring of isCallsStartedMessage
cyrusjc pushed a commit to cyrusjc/mattermost-mobile that referenced this pull request May 18, 2024
…ications while active (mattermost#7623)

* when active, do not show overlay if this is a calls-started notification

* add calls notification type; keep message test for backwards compat

* process calls notifications properly

* revert NOTIFICATION_TYPE.CALLS; use sub_type for backwards compatibility

* add ticket and comment for future refactoring of isCallsStartedMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants