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

refactor: generate notification incoming/missed call - WPB-11664 #2397

Open
wants to merge 3 commits into
base: refactor/generate-notification-new-messages
Choose a base branch
from

Conversation

jullianm
Copy link
Contributor

@jullianm jullianm commented Jan 17, 2025

TaskWPB-11664 [iOS] Generate UNNotificationContent for incoming call

Key points

This PR is about generating notification content related to calling events (incoming call, missed call) which can be either handled by the CallKitNotificationBuilder which will show the built-in CallKit notification or by the CallNotificationBuilder in case we only need to show a regular push notification.

Logic to decide which builder to use is done through the shouldBuildNotification() method in order to be consistent with the new NSE structure.

Testing

  • A CallKit notification is correctly generated.
  • A "regular" call notification is correctly generated.

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

@echoes-hq echoes-hq bot added echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. echoes/initiative: ios-sync-refactoring labels Jan 17, 2025
@jullianm jullianm changed the title refactor: generate notification incoming call - WPB-11664 refactor: generate notification incoming/missed call - WPB-11664 Jan 17, 2025
@jullianm jullianm requested review from johnxnguyen and netbe January 17, 2025 16:23
Copy link
Contributor

Test Results

    3 files      4 suites   4m 41s ⏱️
3 342 tests 3 314 ✅ 28 💤 0 ❌
3 352 runs  3 324 ✅ 28 💤 0 ❌

Results for commit 834df05.

@datadog-wireapp
Copy link

Datadog Report

Branch report: refactor/generate-notification-incoming-call
Commit report: e988af3
Test service: wire-ios-mono

✅ 0 Failed, 3203 Passed, 28 Skipped, 2m 16.62s Total Time

@echoes-hq echoes-hq bot removed the echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. label Feb 5, 2025
Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

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

left some comments before approval

Comment on lines +46 to +58
static func decode(from calling: Calling) -> Self? {
let decoder = JSONDecoder()

guard let data = calling.content.data(using: .utf8) else {
return nil
}

do {
return try decoder.decode(Self.self, from: data)
} catch {
return nil
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: why do we silence error here?

Comment on lines +136 to +138
let isAVSReady = userDefaults.bool(forKey: "isAVSReady")
let isCallKitReady = userDefaults.bool(forKey: "isCallKitAvailable")
let loadedUserSessions = userDefaults.object(forKey: "loadedUserSessions") as? [String] ?? []
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: use constants

Comment on lines +31 to +33
let isStartCall = callContent.type.isOne(of: ["SETUP", "GROUPSTART", "CONFSTART"])
let isIncomingCall = isStartCall && !callContent.resp
let isEndCall = callContent.type.isOne(of: ["CANCEL", "GROUPEND", "CONFEND"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: this is common to callkitNOtificationBuilder, using constants for types could help making sure we use the same

case .missedCall:
buildMissedCallNotification()
case .unhandled:
fatalError()
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: let's log a warning here instead of crashing

// if not we fallback to the regular call notification builder.
if let callKitBuilder, await callKitBuilder.shouldBuildNotification() {
return callKitBuilder
} else if let callNotifBuilder = await makeCallRegularNotificationBuilder(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpic: don't shorten variable

Suggested change
} else if let callNotifBuilder = await makeCallRegularNotificationBuilder(
} else if let callNotificationBuilder = await makeCallRegularNotificationBuilder(

)
}

func shouldBuildNotification() async -> Bool {
!context.isMessageSilenced
!context.isMessageSilenced && !context.isConversationReadOnly
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: is it related? it makes me think about WPB-8946 (bug: notifications shown even though availability is busy or away).


}

func testGenerateCallNotification_Should_Build_Notification_Returns_False() async {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func testGenerateCallNotification_Should_Build_Notification_Returns_False() async {
func testGenerateCallNotification_IsOneOnOne_Team_Should_Build_Notification_Returns_False() async {

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.

2 participants