chore: fix muting sign in emails - skip e2e (#2859)
* chore: fix muting sign in emails - skip e2e * chore: fix api version for e2e tests
This commit is contained in:
@@ -206,6 +206,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
||||
'identifier',
|
||||
'defaultHost',
|
||||
'appVersion',
|
||||
'apiVersion',
|
||||
]
|
||||
|
||||
for (const optionName of requiredOptions) {
|
||||
|
||||
@@ -588,6 +588,26 @@ export class LegacyApiService
|
||||
})
|
||||
}
|
||||
|
||||
async updateSubscriptionSetting(
|
||||
userUuid: UuidString,
|
||||
settingName: string,
|
||||
settingValue: string | null,
|
||||
sensitive: boolean,
|
||||
): Promise<HttpResponse<UpdateSettingResponse>> {
|
||||
const params = {
|
||||
name: settingName,
|
||||
value: settingValue,
|
||||
sensitive: sensitive,
|
||||
}
|
||||
return this.tokenRefreshableRequest<UpdateSettingResponse>({
|
||||
verb: HttpVerb.Put,
|
||||
url: joinPaths(this.host, Paths.v1.subscriptionSettings(userUuid)),
|
||||
authentication: this.getSessionAccessToken(),
|
||||
fallbackErrorMessage: API_MESSAGE_FAILED_UPDATE_SETTINGS,
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
async deleteSetting(userUuid: UuidString, settingName: string): Promise<HttpResponse<DeleteSettingResponse>> {
|
||||
return this.tokenRefreshableRequest<DeleteSettingResponse>({
|
||||
verb: HttpVerb.Delete,
|
||||
|
||||
@@ -42,6 +42,7 @@ const SettingsPaths = {
|
||||
setting: (userUuid: string, settingName: string) => `/v1/users/${userUuid}/settings/${settingName}`,
|
||||
subscriptionSetting: (userUuid: string, settingName: string) =>
|
||||
`/v1/users/${userUuid}/subscription-settings/${settingName}`,
|
||||
subscriptionSettings: (userUuid: string) => `/v1/users/${userUuid}/subscription-settings`,
|
||||
}
|
||||
|
||||
const SubscriptionPaths = {
|
||||
|
||||
@@ -38,6 +38,10 @@ export class SettingsService extends AbstractService implements SettingsClientIn
|
||||
return this.provider.getSubscriptionSetting(name)
|
||||
}
|
||||
|
||||
async updateSubscriptionSetting(name: SettingName, payload: string, sensitive = false) {
|
||||
return this.provider.updateSetting(name, payload, sensitive)
|
||||
}
|
||||
|
||||
async updateSetting(name: SettingName, payload: string, sensitive = false) {
|
||||
return this.provider.updateSetting(name, payload, sensitive)
|
||||
}
|
||||
|
||||
@@ -21,5 +21,12 @@ export interface SettingsServerInterface {
|
||||
|
||||
getSubscriptionSetting(userUuid: UuidString, settingName: string): Promise<HttpResponse<GetSettingResponse>>
|
||||
|
||||
updateSubscriptionSetting(
|
||||
userUuid: UuidString,
|
||||
settingName: string,
|
||||
settingValue: string,
|
||||
sensitive: boolean,
|
||||
): Promise<HttpResponse<UpdateSettingResponse>>
|
||||
|
||||
deleteSetting(userUuid: UuidString, settingName: string): Promise<HttpResponse<DeleteSettingResponse>>
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export function createApplicationWithOptions({ identifier, environment, platform
|
||||
defaultHost: host || Defaults.getDefaultHost(),
|
||||
appVersion: Defaults.getAppVersion(),
|
||||
webSocketUrl: Defaults.getDefaultWebSocketUrl(),
|
||||
apiVersion: ApiVersion.V1,
|
||||
apiVersion: ApiVersion.v0,
|
||||
syncCallsThresholdPerMinute,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,6 +42,16 @@ const Email: FunctionComponent<Props> = ({ application }: Props) => {
|
||||
}
|
||||
}
|
||||
|
||||
const updateSubscriptionSetting = async (settingName: SettingName, payload: string): Promise<boolean> => {
|
||||
try {
|
||||
await application.settings.updateSubscriptionSetting(settingName, payload, false)
|
||||
return true
|
||||
} catch (e) {
|
||||
application.alerts.alert(STRING_FAILED_TO_UPDATE_USER_SETTING).catch(console.error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const loadSettings = useCallback(async () => {
|
||||
if (!application.sessions.getUser()) {
|
||||
return
|
||||
@@ -79,7 +89,7 @@ const Email: FunctionComponent<Props> = ({ application }: Props) => {
|
||||
previousValue === MuteSignInEmailsOption.Muted ? MuteSignInEmailsOption.NotMuted : MuteSignInEmailsOption.Muted
|
||||
setSignInEmailsMutedValue(newValue)
|
||||
|
||||
const updateResult = await updateSetting(
|
||||
const updateResult = await updateSubscriptionSetting(
|
||||
SettingName.create(SettingName.NAMES.MuteSignInEmails).getValue(),
|
||||
newValue,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user