Skip to content

Fix logic for adding email/sms subscriptions#1263

Closed
fadi-george wants to merge 3 commits intomainfrom
fg/email-fix
Closed

Fix logic for adding email/sms subscriptions#1263
fadi-george wants to merge 3 commits intomainfrom
fg/email-fix

Conversation

@fadi-george
Copy link
Copy Markdown
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 jkasten2 and sherwinski and removed request for sherwinski April 8, 2025 23:01
Comment thread src/onesignal/User.ts
public getLanguage(): string {
logMethodCall('getLanguage');
return OneSignal.coreDirector.getPropertiesModel()?.data?.language;
return OneSignal.coreDirector.getPropertiesModel()?.data?.language || '';
Copy link
Copy Markdown
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?

Comment thread src/onesignal/User.ts
* 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
Copy Markdown
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.

@fadi-george
Copy link
Copy Markdown
Contributor Author

Closing in favor web refactor change

@fadi-george fadi-george closed this Jun 2, 2025
@fadi-george fadi-george deleted the fg/email-fix branch August 27, 2025 18:39
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