chore: remove calling payments server for subscriptions if using third party api hosts (#2398)

This commit is contained in:
Karol Sójko
2023-08-09 13:16:19 +02:00
committed by GitHub
parent e05d8c9e76
commit 90dcb33a44
24 changed files with 233 additions and 89 deletions

View File

@@ -1,13 +1,14 @@
import { LEGACY_PROD_EXT_ORIGIN, PROD_OFFLINE_FEATURES_URL } from '@Lib/Hosts'
import { SNFeatureRepo } from '@standardnotes/models'
import { MutatorClientInterface } from '@standardnotes/services'
export class MigrateFeatureRepoToOfflineEntitlementsUseCase {
private readonly LEGACY_PROD_EXT_ORIGIN = 'https://extensions.standardnotes.org'
constructor(private mutator: MutatorClientInterface) {}
async execute(featureRepos: SNFeatureRepo[] = []): Promise<SNFeatureRepo[]> {
async execute(dto: { featureRepos: SNFeatureRepo[]; prodOfflineFeaturesUrl: string }): Promise<SNFeatureRepo[]> {
const updatedRepos: SNFeatureRepo[] = []
for (const item of featureRepos) {
for (const item of dto.featureRepos) {
if (item.migratedToOfflineEntitlements) {
continue
}
@@ -19,7 +20,7 @@ export class MigrateFeatureRepoToOfflineEntitlementsUseCase {
const repoUrl = item.onlineUrl
const { origin } = new URL(repoUrl)
if (!origin.includes(LEGACY_PROD_EXT_ORIGIN)) {
if (!origin.includes(this.LEGACY_PROD_EXT_ORIGIN)) {
continue
}
@@ -28,7 +29,7 @@ export class MigrateFeatureRepoToOfflineEntitlementsUseCase {
const userKey = userKeyMatch[0]
const updatedRepo = await this.mutator.changeFeatureRepo(item, (m) => {
m.offlineFeaturesUrl = PROD_OFFLINE_FEATURES_URL
m.offlineFeaturesUrl = dto.prodOfflineFeaturesUrl
m.offlineKey = userKey
m.migratedToOfflineEntitlements = true
})