Skip to content

Fix logic for adding email/sms subscriptions #1263

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

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

Conversation

fadi-george
Copy link
Contributor

@fadi-george fadi-george commented Apr 8, 2025

Description

1 Line Summary

  • checks for existing subscriptions before adding new ones for email and sms

Details

addSms and addEmail methods both do something like

   const newSubscription = new OSModel<SupportedModel>(
      ModelName.Subscriptions,
      subscription,
    );

so a new model key/id is made so creating new records in subscriptions table (edited)

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

@fadi-george fadi-george requested review from sherwinski and jkasten2 and removed request for sherwinski April 8, 2025 23:01
@@ -384,6 +363,57 @@ export default class User {

public getLanguage(): string {
logMethodCall('getLanguage');
return OneSignal.coreDirector.getPropertiesModel()?.data?.language;
return OneSignal.coreDirector.getPropertiesModel()?.data?.language || '';
Copy link
Member

@jkasten2 jkasten2 Apr 15, 2025

Choose a reason for hiding this comment

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

This language change is unrelated to the scope of the PR. Was this an intended logic change?

* Retrieves subscription models that match the given token and optionally OneSignal ID
* @param token - The token to search for in subscriptions
* @param onesignalId - Optional OneSignal ID to filter by
* @returns matching getSubscriptionModel and deletes duplicate subscriptions
Copy link
Member

Choose a reason for hiding this comment

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

nit, the "... and deletes duplicate subscriptions" noted here doesn't describe the return value, but rather the side-effect of calling this function. Can we move this note to the function description. Lastly I would use the term "cleanup" rather than "delete" as it's a bit more specific here.

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.

3 participants