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

Allow sending push notifications to multiple identities and with dynamic text #939

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

tnotheis
Copy link
Member

Readiness checklist

  • I added/updated unit tests.
  • I added/updated integration tests.
  • I ensured that the PR title is good enough for the changelog.
  • I labeled the PR.

@tnotheis tnotheis added refactoring Refactoring of code wip Work in Progress labels Nov 14, 2024
@tnotheis tnotheis self-assigned this Nov 14, 2024
@tnotheis tnotheis changed the title Allow sending push notifications with dynamic text Allow sending push notifications to multiple identities and with dynamic text Nov 14, 2024
Copy link
Member Author

Choose a reason for hiding this comment

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

Hint for reviewer: I simplified the Send method of the connectors a lot. Before my change, you were able to pass multiple registrations, and the Send method sent a push notification to each of them.

Now you can only pass one registration.

Another change to this file was the addition of a notificationText parameter, which serves the purpose of this PR (being able to dynamically pass a text). It's now the responsibility of the PushService to read the notification text from the resource dictionary, or just forward the one it receives from the caller.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hint for reviewer: (same as for the ApplePushNotificationServiceConnector)

Task SendFilteredNotification(IdentityAddress recipient, IPushNotification notification, IEnumerable<string> excludedDevices, CancellationToken cancellationToken);
Task SendNotification(IPushNotification notification, SendPushNotificationFilter filter, CancellationToken cancellationToken);

Task SendNotification(IPushNotification notification, SendPushNotificationFilter filter, Dictionary<string, NotificationText> notificationTexts,
Copy link
Member Author

Choose a reason for hiding this comment

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

Hint for reviewer: this is one of the main purposes of this PR. I added this overload, which accepts an additional parameter notificationTexts, which is a dictionary, where the key is the language and the value is the text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hint for reviewer: The other important change in this file is the addition of the filter parameter. This replaces the recipient parameter, as well as the excludedDevices parameter, which allowed me to get rid of the SendFilteredNotification method.

It also enables me to pass multiple recipients by adding multiple addresses to the SendPushNotificationFilter.IncludedIdentities property.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hint for reviewer: I deleted most of the tests in this class, because:

  1. I made a simplification of the DeleteRegistration method, which makes the test useless, as the new implementation just forwards the call to the repository.
  2. The new SendNotification method is very hard to test. I couldn't find a better design though. :( Maybe some day we can come up with a better approach. (manual tests were successful)

@tnotheis tnotheis marked this pull request as ready for review November 15, 2024 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring of code wip Work in Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant