From 73546ba2917885b82776f068e2ce2366b5b42325 Mon Sep 17 00:00:00 2001 From: Sam Peters Date: Tue, 16 Jan 2024 15:01:17 -0600 Subject: [PATCH] feat(core): proxy notification settings operations --- core/api/package.json | 2 +- .../accounts/disable-notification-category.ts | 15 +- .../accounts/disable-notification-channel.ts | 12 +- .../accounts/enable-notification-category.ts | 15 +- .../accounts/enable-notification-channel.ts | 12 +- .../get-notification-settings-for-account.ts | 11 + core/api/src/app/accounts/index.ts | 1 + core/api/src/config/env.ts | 11 + core/api/src/config/index.ts | 2 + core/api/src/domain/notifications/index.ts | 162 +- .../src/domain/notifications/index.types.d.ts | 26 + .../public/types/object/consumer-account.ts | 12 +- .../api/src/services/notifications/convert.ts | 78 + .../src/services/notifications/grpc-client.ts | 67 + core/api/src/services/notifications/index.ts | 174 ++ .../services/notifications/proto/buf.gen.yaml | 15 + .../notifications/proto/notifications.proto | 91 + .../proto/notifications_grpc_pb.d.ts | 127 + .../proto/notifications_grpc_pb.js | 210 ++ .../notifications/proto/notifications_pb.d.ts | 347 +++ .../notifications/proto/notifications_pb.js | 2625 +++++++++++++++++ .../unit/domain/notifications/index.spec.ts | 172 -- dev/Tiltfile | 1 + 23 files changed, 3840 insertions(+), 348 deletions(-) create mode 100644 core/api/src/app/accounts/get-notification-settings-for-account.ts create mode 100644 core/api/src/services/notifications/convert.ts create mode 100644 core/api/src/services/notifications/grpc-client.ts create mode 100644 core/api/src/services/notifications/proto/buf.gen.yaml create mode 100644 core/api/src/services/notifications/proto/notifications.proto create mode 100644 core/api/src/services/notifications/proto/notifications_grpc_pb.d.ts create mode 100644 core/api/src/services/notifications/proto/notifications_grpc_pb.js create mode 100644 core/api/src/services/notifications/proto/notifications_pb.d.ts create mode 100644 core/api/src/services/notifications/proto/notifications_pb.js delete mode 100644 core/api/test/unit/domain/notifications/index.spec.ts diff --git a/core/api/package.json b/core/api/package.json index c65e1f2e57..82b0c4c32d 100644 --- a/core/api/package.json +++ b/core/api/package.json @@ -5,7 +5,7 @@ "eslint-check": "eslint src test --ext .ts", "eslint-fix": "eslint src test --ext .ts --fix", "circular-deps-check": "madge --circular --extensions ts src", - "build": "tsc -p tsconfig-build.json && cp -R src/services/price/protos dist/services/price/ && cp -R src/services/dealer-price/proto dist/services/dealer-price/ && cp -R src/services/loopd/protos dist/services/loopd/ && cp -R src/services/bria/proto dist/services/bria/ && tscpaths --silent -p tsconfig.json -s ./src -o ./dist", + "build": "tsc -p tsconfig-build.json && cp -R src/services/price/protos dist/services/price/ && cp -R src/services/dealer-price/proto dist/services/dealer-price/ && cp -R src/services/loopd/protos dist/services/loopd/ && cp -R src/services/bria/proto dist/services/bria/ && cp -R src/services/notifications/proto dist/services/notifications/ && tscpaths --silent -p tsconfig.json -s ./src -o ./dist", "trigger": "pnpm run build && node dist/servers/trigger.js | pino-pretty -c -l", "ws": "pnpm run build && node dist/servers/ws-server.js | pino-pretty -c -l", "watch": "nodemon -V -e ts,graphql -w ./src -x pnpm run start", diff --git a/core/api/src/app/accounts/disable-notification-category.ts b/core/api/src/app/accounts/disable-notification-category.ts index 1d38544ac6..c1c5dd5316 100644 --- a/core/api/src/app/accounts/disable-notification-category.ts +++ b/core/api/src/app/accounts/disable-notification-category.ts @@ -1,8 +1,9 @@ import { + NotificationChannel, checkedToNotificationCategory, - disableNotificationCategory as domainDisableNotificationCategory, } from "@/domain/notifications" import { AccountsRepository } from "@/services/mongoose" +import { NotificationsService } from "@/services/notifications" export const disableNotificationCategory = async ({ accountId, @@ -19,13 +20,15 @@ export const disableNotificationCategory = async ({ const account = await AccountsRepository().findById(accountId) if (account instanceof Error) return account - const newNotificationSettings = domainDisableNotificationCategory({ - notificationSettings: account.notificationSettings, - notificationChannel, + const notificationsService = NotificationsService() + + const newNotificationSettings = await notificationsService.disableNotificationCategory({ + userId: account.kratosUserId, + notificationChannel: notificationChannel || NotificationChannel.Push, notificationCategory: checkedNotificationCategory, }) - account.notificationSettings = newNotificationSettings + if (newNotificationSettings instanceof Error) return newNotificationSettings - return AccountsRepository().update(account) + return account } diff --git a/core/api/src/app/accounts/disable-notification-channel.ts b/core/api/src/app/accounts/disable-notification-channel.ts index d0b7d4d050..df4746d1fa 100644 --- a/core/api/src/app/accounts/disable-notification-channel.ts +++ b/core/api/src/app/accounts/disable-notification-channel.ts @@ -1,5 +1,5 @@ -import { disableNotificationChannel as domainDisableNotificationChannel } from "@/domain/notifications" import { AccountsRepository } from "@/services/mongoose" +import { NotificationsService } from "@/services/notifications" export const disableNotificationChannel = async ({ accountId, @@ -11,12 +11,14 @@ export const disableNotificationChannel = async ({ const account = await AccountsRepository().findById(accountId) if (account instanceof Error) return account - const newNotificationSettings = domainDisableNotificationChannel({ - notificationSettings: account.notificationSettings, + const notificationsService = NotificationsService() + + const newNotificationSettings = await notificationsService.disableNotificationChannel({ + userId: account.kratosUserId, notificationChannel, }) - account.notificationSettings = newNotificationSettings + if (newNotificationSettings instanceof Error) return newNotificationSettings - return AccountsRepository().update(account) + return account } diff --git a/core/api/src/app/accounts/enable-notification-category.ts b/core/api/src/app/accounts/enable-notification-category.ts index a2b03be64f..1376ef1fe2 100644 --- a/core/api/src/app/accounts/enable-notification-category.ts +++ b/core/api/src/app/accounts/enable-notification-category.ts @@ -1,8 +1,9 @@ import { + NotificationChannel, checkedToNotificationCategory, - enableNotificationCategory as domainEnableNotificationCategory, } from "@/domain/notifications" import { AccountsRepository } from "@/services/mongoose" +import { NotificationsService } from "@/services/notifications" export const enableNotificationCategory = async ({ accountId, @@ -19,13 +20,15 @@ export const enableNotificationCategory = async ({ const account = await AccountsRepository().findById(accountId) if (account instanceof Error) return account - const newNotificationSettings = domainEnableNotificationCategory({ - notificationSettings: account.notificationSettings, - notificationChannel, + const notificationsService = NotificationsService() + + const newNotificationSettings = await notificationsService.enableNotificationCategory({ + userId: account.kratosUserId, + notificationChannel: notificationChannel || NotificationChannel.Push, notificationCategory: checkedNotificationCategory, }) - account.notificationSettings = newNotificationSettings + if (newNotificationSettings instanceof Error) return newNotificationSettings - return AccountsRepository().update(account) + return account } diff --git a/core/api/src/app/accounts/enable-notification-channel.ts b/core/api/src/app/accounts/enable-notification-channel.ts index 834bb3b23d..2d49839c79 100644 --- a/core/api/src/app/accounts/enable-notification-channel.ts +++ b/core/api/src/app/accounts/enable-notification-channel.ts @@ -1,5 +1,5 @@ -import { enableNotificationChannel as domainEnableNotificationChannel } from "@/domain/notifications" import { AccountsRepository } from "@/services/mongoose" +import { NotificationsService } from "@/services/notifications" export const enableNotificationChannel = async ({ accountId, @@ -11,12 +11,14 @@ export const enableNotificationChannel = async ({ const account = await AccountsRepository().findById(accountId) if (account instanceof Error) return account - const newNotificationSettings = domainEnableNotificationChannel({ - notificationSettings: account.notificationSettings, + const notificationsService = NotificationsService() + + const newNotificationSettings = await notificationsService.enableNotificationChannel({ + userId: account.kratosUserId, notificationChannel, }) - account.notificationSettings = newNotificationSettings + if (newNotificationSettings instanceof Error) return newNotificationSettings - return AccountsRepository().update(account) + return account } diff --git a/core/api/src/app/accounts/get-notification-settings-for-account.ts b/core/api/src/app/accounts/get-notification-settings-for-account.ts new file mode 100644 index 0000000000..7818671465 --- /dev/null +++ b/core/api/src/app/accounts/get-notification-settings-for-account.ts @@ -0,0 +1,11 @@ +import { NotificationsService } from "@/services/notifications" + +export const getNotificationSettingsForAccount = ({ + account, +}: { + account: Account +}): Promise => { + const notificationsService = NotificationsService() + + return notificationsService.getUserNotificationSettings(account.kratosUserId) +} diff --git a/core/api/src/app/accounts/index.ts b/core/api/src/app/accounts/index.ts index 073971d171..71fbff0a60 100644 --- a/core/api/src/app/accounts/index.ts +++ b/core/api/src/app/accounts/index.ts @@ -26,6 +26,7 @@ export * from "./enable-notification-channel" export * from "./disable-notification-channel" export * from "./get-pending-incoming-on-chain-transactions-for-account" export * from "./get-invoices-for-account" +export * from "./get-notification-settings-for-account" const accounts = AccountsRepository() diff --git a/core/api/src/config/env.ts b/core/api/src/config/env.ts index 73aedfad13..fcb7a814a4 100644 --- a/core/api/src/config/env.ts +++ b/core/api/src/config/env.ts @@ -50,6 +50,14 @@ export const env = createEnv({ BRIA_PORT: z.number().min(1).or(z.string()).pipe(z.coerce.number()).default(2742), BRIA_API_KEY: z.string().min(1), + NOTIFICATIONS_HOST: z.string().min(1), + NOTIFICATIONS_PORT: z + .number() + .min(1) + .or(z.string()) + .pipe(z.coerce.number()) + .default(6685), + GEETEST_ID: z.string().min(1).optional(), GEETEST_KEY: z.string().min(1).optional(), @@ -168,6 +176,9 @@ export const env = createEnv({ BRIA_PORT: process.env.BRIA_PORT, BRIA_API_KEY: process.env.BRIA_API_KEY, + NOTIFICATIONS_HOST: process.env.NOTIFICATIONS_HOST, + NOTIFICATIONS_PORT: process.env.NOTIFICATIONS_PORT, + GEETEST_ID: process.env.GEETEST_ID, GEETEST_KEY: process.env.GEETEST_KEY, diff --git a/core/api/src/config/index.ts b/core/api/src/config/index.ts index b331e05358..bb832944c1 100644 --- a/core/api/src/config/index.ts +++ b/core/api/src/config/index.ts @@ -121,6 +121,8 @@ export const KRATOS_CALLBACK_API_KEY = env.KRATOS_CALLBACK_API_KEY export const BRIA_HOST = env.BRIA_HOST export const BRIA_PORT = env.BRIA_PORT export const BRIA_API_KEY = env.BRIA_API_KEY +export const NOTIFICATIONS_HOST = env.NOTIFICATIONS_HOST +export const NOTIFICATIONS_PORT = env.NOTIFICATIONS_PORT export const GEETEST_ID = env.GEETEST_ID export const GEETEST_KEY = env.GEETEST_KEY export const MONGODB_CON = env.MONGODB_CON diff --git a/core/api/src/domain/notifications/index.ts b/core/api/src/domain/notifications/index.ts index 2a84a9e302..58a526671d 100644 --- a/core/api/src/domain/notifications/index.ts +++ b/core/api/src/domain/notifications/index.ts @@ -1,6 +1,5 @@ -import { InvalidPushNotificationSettingError as InvalidNotificationSettingsError } from "./errors" - export * from "./errors" +import { InvalidPushNotificationSettingError } from "./errors" export const NotificationType = { IntraLedgerReceipt: "intra_ledger_receipt", @@ -12,164 +11,23 @@ export const NotificationType = { LigtningPayment: "lightning_payment", } as const -export const NotificationChannel = { - Push: "push", -} as const - -export const GaloyNotificationCategories = { - Payments: "Payments" as NotificationCategory, - Balance: "Balance" as NotificationCategory, - AdminPushNotification: "AdminPushNotification" as NotificationCategory, -} as const - export const checkedToNotificationCategory = ( notificationCategory: string, ): NotificationCategory | ValidationError => { // TODO: add validation if (!notificationCategory) { - return new InvalidNotificationSettingsError("Invalid notification category") + return new InvalidPushNotificationSettingError("Invalid notification category") } return notificationCategory as NotificationCategory } -export const enableNotificationChannel = ({ - notificationSettings, - notificationChannel, -}: { - notificationSettings: NotificationSettings - notificationChannel: NotificationChannel -}): NotificationSettings => { - return setNotificationChannelIsEnabled({ - notificationSettings, - notificationChannel, - enabled: true, - }) -} - -export const disableNotificationChannel = ({ - notificationSettings, - notificationChannel, -}: { - notificationSettings: NotificationSettings - notificationChannel: NotificationChannel -}): NotificationSettings => { - return setNotificationChannelIsEnabled({ - notificationSettings, - notificationChannel, - enabled: false, - }) -} - -const setNotificationChannelIsEnabled = ({ - notificationSettings, - notificationChannel, - enabled, -}: { - notificationSettings: NotificationSettings - notificationChannel: NotificationChannel - enabled: boolean -}): NotificationSettings => { - const notificationChannelSettings = notificationSettings[notificationChannel] - const enabledChanged = notificationChannelSettings.enabled !== enabled - - const newNotificationSettings = { - enabled, - disabledCategories: enabledChanged - ? [] - : notificationChannelSettings.disabledCategories, - } - - return { - ...notificationSettings, - [notificationChannel]: newNotificationSettings, - } -} - -export const enableNotificationCategory = ({ - notificationSettings, - notificationChannel, - notificationCategory, -}: { - notificationSettings: NotificationSettings - notificationChannel?: NotificationChannel - notificationCategory: NotificationCategory -}): NotificationSettings => { - const notificationChannelsToUpdate: NotificationChannel[] = notificationChannel - ? [notificationChannel] - : Object.values(NotificationChannel) - - let newNotificationSettings = notificationSettings - - for (const notificationChannel of notificationChannelsToUpdate) { - const notificationChannelSettings = notificationSettings[notificationChannel] - const disabledCategories = notificationChannelSettings.disabledCategories - - const newNotificationChannelSettings = { - enabled: notificationChannelSettings.enabled, - disabledCategories: disabledCategories.filter( - (category) => category !== notificationCategory, - ), - } - - newNotificationSettings = { - ...notificationSettings, - [notificationChannel]: newNotificationChannelSettings, - } - } - - return newNotificationSettings -} - -export const disableNotificationCategory = ({ - notificationSettings, - notificationChannel, - notificationCategory, -}: { - notificationSettings: NotificationSettings - notificationChannel?: NotificationChannel - notificationCategory: NotificationCategory -}): NotificationSettings => { - const notificationChannelsToUpdate: NotificationChannel[] = notificationChannel - ? [notificationChannel] - : Object.values(NotificationChannel) - - let newNotificationSettings = notificationSettings - - for (const notificationChannel of notificationChannelsToUpdate) { - const notificationChannelSettings = notificationSettings[notificationChannel] - const disabledCategories = notificationChannelSettings.disabledCategories - disabledCategories.push(notificationCategory) - const uniqueDisabledCategories = [...new Set(disabledCategories)] - - const newNotificationChannelSettings = { - enabled: notificationChannelSettings.enabled, - disabledCategories: uniqueDisabledCategories, - } - - newNotificationSettings = { - ...notificationSettings, - [notificationChannel]: newNotificationChannelSettings, - } - } - - return newNotificationSettings -} - -export const shouldSendNotification = ({ - notificationChannel, - notificationSettings, - notificationCategory, -}: { - notificationChannel: NotificationChannel - notificationSettings: NotificationSettings - notificationCategory: NotificationCategory -}): boolean => { - const channelNotificationSettings = notificationSettings[notificationChannel] - - if (channelNotificationSettings.enabled) { - return !channelNotificationSettings.disabledCategories.includes(notificationCategory) - } +export const NotificationChannel = { + Push: "push", +} as const - return false -} +export const GaloyNotificationCategories = { + Payments: "Payments" as NotificationCategory, + Balance: "Balance" as NotificationCategory, + AdminPushNotification: "AdminPushNotification" as NotificationCategory, +} as const diff --git a/core/api/src/domain/notifications/index.types.d.ts b/core/api/src/domain/notifications/index.types.d.ts index 0308979ab0..de31c422f7 100644 --- a/core/api/src/domain/notifications/index.types.d.ts +++ b/core/api/src/domain/notifications/index.types.d.ts @@ -53,4 +53,30 @@ interface INotificationsService { adminPushNotificationFilteredSend( args: SendFilteredPushNotificationArgs, ): Promise + + getUserNotificationSettings( + userId: UserId, + ): Promise + + enableNotificationChannel(args: { + userId: UserId + notificationChannel: NotificationChannel + }): Promise + + disableNotificationChannel(args: { + userId: UserId + notificationChannel: NotificationChannel + }): Promise + + enableNotificationCategory(args: { + userId: UserId + notificationChannel: NotificationChannel + notificationCategory: NotificationCategory + }): Promise + + disableNotificationCategory(args: { + userId: UserId + notificationChannel: NotificationChannel + notificationCategory: NotificationCategory + }): Promise } diff --git a/core/api/src/graphql/public/types/object/consumer-account.ts b/core/api/src/graphql/public/types/object/consumer-account.ts index 55c057f48c..d84fde0852 100644 --- a/core/api/src/graphql/public/types/object/consumer-account.ts +++ b/core/api/src/graphql/public/types/object/consumer-account.ts @@ -256,7 +256,17 @@ const ConsumerAccount = GT.Object({ }, notificationSettings: { type: GT.NonNull(NotificationSettings), - resolve: (source) => source.notificationSettings, + resolve: async (source) => { + const result = await Accounts.getNotificationSettingsForAccount({ + account: source, + }) + + if (result instanceof Error) { + throw mapError(result) + } + + return result + }, }, }), }) diff --git a/core/api/src/services/notifications/convert.ts b/core/api/src/services/notifications/convert.ts new file mode 100644 index 0000000000..a336155634 --- /dev/null +++ b/core/api/src/services/notifications/convert.ts @@ -0,0 +1,78 @@ +import { + UserNotificationSettings as GrpcNotificationSettings, + NotificationCategory as GrpcNotificationCategory, + NotificationChannel as GrpcNotificationChannel, +} from "./proto/notifications_pb" + +import { + GaloyNotificationCategories, + InvalidPushNotificationSettingError, + NotificationChannel, +} from "@/domain/notifications" + +export const grpcNotificationSettingsToNotificationSettings = ( + settings: GrpcNotificationSettings | undefined, +): NotificationSettings | InvalidPushNotificationSettingError => { + if (!settings) return new InvalidPushNotificationSettingError("No settings provided") + + const pushSettings = settings.getPush() + if (!pushSettings) + return new InvalidPushNotificationSettingError("No push settings provided") + + const disabledCategories = pushSettings + .getDisabledCategoriesList() + .map(grpcNotificationCategoryToNotificationCategory) + .filter( + (category): category is NotificationCategory => + !(category instanceof InvalidPushNotificationSettingError), + ) + + const notificationSettings: NotificationSettings = { + push: { + enabled: pushSettings.getEnabled(), + disabledCategories, + }, + } + + return notificationSettings +} + +export const grpcNotificationCategoryToNotificationCategory = ( + category: GrpcNotificationCategory, +): NotificationCategory | InvalidPushNotificationSettingError => { + switch (category) { + case GrpcNotificationCategory.PAYMENTS: + return GaloyNotificationCategories.Payments + case GrpcNotificationCategory.CIRCLES: + return "Circles" as NotificationCategory + default: + return new InvalidPushNotificationSettingError( + `Invalid notification category: ${category}`, + ) + } +} + +// TODO: Add support for AdminPushNotification and Balance to Notifications pod +export const notificationCategoryToGrpcNotificationCategory = ( + category: NotificationCategory, +): GrpcNotificationCategory => { + switch (category) { + case GaloyNotificationCategories.Payments: + return GrpcNotificationCategory.PAYMENTS + case "Circles": + return GrpcNotificationCategory.CIRCLES + case GaloyNotificationCategories.AdminPushNotification: + case GaloyNotificationCategories.Balance: + default: + throw new Error(`Not implemented: ${category}`) + } +} + +export const notificationChannelToGrpcNotificationChannel = ( + channel: NotificationChannel, +): GrpcNotificationChannel => { + switch (channel) { + case NotificationChannel.Push: + return GrpcNotificationChannel.PUSH + } +} diff --git a/core/api/src/services/notifications/grpc-client.ts b/core/api/src/services/notifications/grpc-client.ts new file mode 100644 index 0000000000..b6303056df --- /dev/null +++ b/core/api/src/services/notifications/grpc-client.ts @@ -0,0 +1,67 @@ +import { promisify } from "util" + +import { credentials, Metadata } from "@grpc/grpc-js" + +import { NotificationsServiceClient } from "./proto/notifications_grpc_pb" + +import { + ShouldSendNotificationRequest, + ShouldSendNotificationResponse, + UserDisableNotificationCategoryRequest, + UserDisableNotificationCategoryResponse, + UserEnableNotificationCategoryRequest, + UserEnableNotificationCategoryResponse, + UserEnableNotificationChannelRequest, + UserEnableNotificationChannelResponse, + UserDisableNotificationChannelRequest, + UserDisableNotificationChannelResponse, + UserNotificationSettingsRequest, + UserNotificationSettingsResponse, +} from "./proto/notifications_pb" + +import { NOTIFICATIONS_HOST, NOTIFICATIONS_PORT } from "@/config" + +const notificationsEndpoint = `${NOTIFICATIONS_HOST}:${NOTIFICATIONS_PORT}` + +const notificationsClient = new NotificationsServiceClient( + notificationsEndpoint, + credentials.createInsecure(), +) + +export const notificationsMetadata = new Metadata() + +export const shouldSendNotification = promisify< + ShouldSendNotificationRequest, + Metadata, + ShouldSendNotificationResponse +>(notificationsClient.shouldSendNotification.bind(notificationsClient)) + +export const userEnableNotificationCatgeory = promisify< + UserEnableNotificationCategoryRequest, + Metadata, + UserEnableNotificationCategoryResponse +>(notificationsClient.userEnableNotificationCategory.bind(notificationsClient)) + +export const userDisableNotificationCategory = promisify< + UserDisableNotificationCategoryRequest, + Metadata, + UserDisableNotificationCategoryResponse +>(notificationsClient.userDisableNotificationCategory.bind(notificationsClient)) + +export const userEnableNotificationChannel = promisify< + UserEnableNotificationChannelRequest, + Metadata, + UserEnableNotificationChannelResponse +>(notificationsClient.userEnableNotificationChannel.bind(notificationsClient)) + +export const userDisableNotificationChannel = promisify< + UserDisableNotificationChannelRequest, + Metadata, + UserDisableNotificationChannelResponse +>(notificationsClient.userDisableNotificationChannel.bind(notificationsClient)) + +export const userNotificationSettings = promisify< + UserNotificationSettingsRequest, + Metadata, + UserNotificationSettingsResponse +>(notificationsClient.userNotificationSettings.bind(notificationsClient)) diff --git a/core/api/src/services/notifications/index.ts b/core/api/src/services/notifications/index.ts index 47c0c9eab4..014b4a8114 100644 --- a/core/api/src/services/notifications/index.ts +++ b/core/api/src/services/notifications/index.ts @@ -5,6 +5,22 @@ import { import { createPushNotificationContent } from "./create-push-notification-content" +import { + UserDisableNotificationCategoryRequest, + UserDisableNotificationChannelRequest, + UserEnableNotificationCategoryRequest, + UserEnableNotificationChannelRequest, + UserNotificationSettingsRequest, +} from "./proto/notifications_pb" + +import * as notificationsGrpc from "./grpc-client" + +import { + grpcNotificationSettingsToNotificationSettings, + notificationCategoryToGrpcNotificationCategory, + notificationChannelToGrpcNotificationChannel, +} from "./convert" + import { getCallbackServiceConfig } from "@/config" import { @@ -362,6 +378,159 @@ export const NotificationsService = (): INotificationsService => { } } + const getUserNotificationSettings = async ( + userId: UserId, + ): Promise => { + try { + const request = new UserNotificationSettingsRequest() + request.setUserId(userId) + const response = await notificationsGrpc.userNotificationSettings( + request, + notificationsGrpc.notificationsMetadata, + ) + + const notificationSettings = grpcNotificationSettingsToNotificationSettings( + response.getNotificationSettings(), + ) + + return notificationSettings + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + + const enableNotificationChannel = async ({ + userId, + notificationChannel, + }: { + userId: UserId + notificationChannel: NotificationChannel + }): Promise => { + try { + const request = new UserEnableNotificationChannelRequest() + request.setUserId(userId) + + const grpcNotificationChannel = + notificationChannelToGrpcNotificationChannel(notificationChannel) + + request.setChannel(grpcNotificationChannel) + const response = await notificationsGrpc.userEnableNotificationChannel( + request, + notificationsGrpc.notificationsMetadata, + ) + + const notificationSettings = grpcNotificationSettingsToNotificationSettings( + response.getNotificationSettings(), + ) + + return notificationSettings + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + + const disableNotificationChannel = async ({ + userId, + notificationChannel, + }: { + userId: UserId + notificationChannel: NotificationChannel + }): Promise => { + try { + const request = new UserDisableNotificationChannelRequest() + request.setUserId(userId) + + const grpcNotificationChannel = + notificationChannelToGrpcNotificationChannel(notificationChannel) + + request.setChannel(grpcNotificationChannel) + const response = await notificationsGrpc.userDisableNotificationChannel( + request, + notificationsGrpc.notificationsMetadata, + ) + + const notificationSettings = grpcNotificationSettingsToNotificationSettings( + response.getNotificationSettings(), + ) + + return notificationSettings + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + + const enableNotificationCategory = async ({ + userId, + notificationChannel, + notificationCategory, + }: { + userId: UserId + notificationChannel: NotificationChannel + notificationCategory: NotificationCategory + }): Promise => { + try { + const request = new UserEnableNotificationCategoryRequest() + request.setUserId(userId) + + const grpcNotificationChannel = + notificationChannelToGrpcNotificationChannel(notificationChannel) + request.setChannel(grpcNotificationChannel) + + const grpcNotificationCategory = + notificationCategoryToGrpcNotificationCategory(notificationCategory) + request.setCategory(grpcNotificationCategory) + + const response = await notificationsGrpc.userEnableNotificationCatgeory( + request, + notificationsGrpc.notificationsMetadata, + ) + + const notificationSettings = grpcNotificationSettingsToNotificationSettings( + response.getNotificationSettings(), + ) + + return notificationSettings + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + + const disableNotificationCategory = async ({ + userId, + notificationChannel, + notificationCategory, + }: { + userId: UserId + notificationChannel: NotificationChannel + notificationCategory: NotificationCategory + }): Promise => { + try { + const request = new UserDisableNotificationCategoryRequest() + request.setUserId(userId) + + const grpcNotificationChannel = + notificationChannelToGrpcNotificationChannel(notificationChannel) + request.setChannel(grpcNotificationChannel) + + const grpcNotificationCategory = + notificationCategoryToGrpcNotificationCategory(notificationCategory) + request.setCategory(grpcNotificationCategory) + + const response = await notificationsGrpc.userDisableNotificationCategory( + request, + notificationsGrpc.notificationsMetadata, + ) + + const notificationSettings = grpcNotificationSettingsToNotificationSettings( + response.getNotificationSettings(), + ) + + return notificationSettings + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + // trace everything except price update because it runs every 30 seconds return { priceUpdate, @@ -372,6 +541,11 @@ export const NotificationsService = (): INotificationsService => { sendBalance, adminPushNotificationSend, adminPushNotificationFilteredSend, + getUserNotificationSettings, + enableNotificationChannel, + disableNotificationChannel, + enableNotificationCategory, + disableNotificationCategory, }, }), } diff --git a/core/api/src/services/notifications/proto/buf.gen.yaml b/core/api/src/services/notifications/proto/buf.gen.yaml new file mode 100644 index 0000000000..4afda94f7f --- /dev/null +++ b/core/api/src/services/notifications/proto/buf.gen.yaml @@ -0,0 +1,15 @@ +# /proto/buf.gen.yaml +version: v1 + +plugins: + - name: js + out: . + opt: import_style=commonjs,binary + - name: grpc + out: . + opt: grpc_js + path: grpc_tools_node_protoc_plugin + - name: ts + out: . + opt: grpc_js + path: protoc-gen-ts diff --git a/core/api/src/services/notifications/proto/notifications.proto b/core/api/src/services/notifications/proto/notifications.proto new file mode 100644 index 0000000000..34844d60c9 --- /dev/null +++ b/core/api/src/services/notifications/proto/notifications.proto @@ -0,0 +1,91 @@ +syntax = "proto3"; + +import "google/protobuf/struct.proto"; + +package services.notifications.v1; + +service NotificationsService { + rpc ShouldSendNotification (ShouldSendNotificationRequest) returns (ShouldSendNotificationResponse) {} + rpc UserEnableNotificationChannel (UserEnableNotificationChannelRequest) returns (UserEnableNotificationChannelResponse) {} + rpc UserDisableNotificationChannel (UserDisableNotificationChannelRequest) returns (UserDisableNotificationChannelResponse) {} + rpc UserEnableNotificationCategory (UserEnableNotificationCategoryRequest) returns (UserEnableNotificationCategoryResponse) {} + rpc UserDisableNotificationCategory (UserDisableNotificationCategoryRequest) returns (UserDisableNotificationCategoryResponse) {} + rpc UserNotificationSettings (UserNotificationSettingsRequest) returns (UserNotificationSettingsResponse) {} +} + +enum NotificationChannel { + PUSH = 0; +} + +enum NotificationCategory { + CIRCLES = 0; + PAYMENTS = 1; +} + +message ShouldSendNotificationRequest { + string user_id = 1; + NotificationChannel channel = 2; + NotificationCategory category = 3; +} + +message ShouldSendNotificationResponse { + string user_id = 1; + bool should_send = 2; +} + +message UserEnableNotificationChannelRequest { + string user_id = 1; + NotificationChannel channel = 2; +} + +message UserEnableNotificationChannelResponse { + UserNotificationSettings notification_settings = 1; +} + +message UserNotificationSettings { + ChannelNotificationSettings push = 1; +} + +message ChannelNotificationSettings { + bool enabled = 1; + repeated NotificationCategory disabled_categories = 2; +} + +message UserDisableNotificationChannelRequest { + string user_id = 1; + NotificationChannel channel = 2; +} + +message UserDisableNotificationChannelResponse { + UserNotificationSettings notification_settings = 1; +} + +message UserDisableNotificationCategoryRequest { + string user_id = 1; + NotificationChannel channel = 2; + NotificationCategory category = 3; +} + +message UserDisableNotificationCategoryResponse { + UserNotificationSettings notification_settings = 1; +} + +message UserEnableNotificationCategoryRequest { + string user_id = 1; + NotificationChannel channel = 2; + NotificationCategory category = 3; +} + +message UserEnableNotificationCategoryResponse { + UserNotificationSettings notification_settings = 1; +} + +message UserNotificationSettingsRequest { + string user_id = 1; +} + +message UserNotificationSettingsResponse { + UserNotificationSettings notification_settings = 1; +} + + diff --git a/core/api/src/services/notifications/proto/notifications_grpc_pb.d.ts b/core/api/src/services/notifications/proto/notifications_grpc_pb.d.ts new file mode 100644 index 0000000000..0605592af2 --- /dev/null +++ b/core/api/src/services/notifications/proto/notifications_grpc_pb.d.ts @@ -0,0 +1,127 @@ +// package: services.notifications.v1 +// file: notifications.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as notifications_pb from "./notifications_pb"; +import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb"; + +interface INotificationsServiceService extends grpc.ServiceDefinition { + shouldSendNotification: INotificationsServiceService_IShouldSendNotification; + userEnableNotificationChannel: INotificationsServiceService_IUserEnableNotificationChannel; + userDisableNotificationChannel: INotificationsServiceService_IUserDisableNotificationChannel; + userEnableNotificationCategory: INotificationsServiceService_IUserEnableNotificationCategory; + userDisableNotificationCategory: INotificationsServiceService_IUserDisableNotificationCategory; + userNotificationSettings: INotificationsServiceService_IUserNotificationSettings; +} + +interface INotificationsServiceService_IShouldSendNotification extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/ShouldSendNotification"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IUserEnableNotificationChannel extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/UserEnableNotificationChannel"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IUserDisableNotificationChannel extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/UserDisableNotificationChannel"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IUserEnableNotificationCategory extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/UserEnableNotificationCategory"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IUserDisableNotificationCategory extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/UserDisableNotificationCategory"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IUserNotificationSettings extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/UserNotificationSettings"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const NotificationsServiceService: INotificationsServiceService; + +export interface INotificationsServiceServer extends grpc.UntypedServiceImplementation { + shouldSendNotification: grpc.handleUnaryCall; + userEnableNotificationChannel: grpc.handleUnaryCall; + userDisableNotificationChannel: grpc.handleUnaryCall; + userEnableNotificationCategory: grpc.handleUnaryCall; + userDisableNotificationCategory: grpc.handleUnaryCall; + userNotificationSettings: grpc.handleUnaryCall; +} + +export interface INotificationsServiceClient { + shouldSendNotification(request: notifications_pb.ShouldSendNotificationRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.ShouldSendNotificationResponse) => void): grpc.ClientUnaryCall; + shouldSendNotification(request: notifications_pb.ShouldSendNotificationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.ShouldSendNotificationResponse) => void): grpc.ClientUnaryCall; + shouldSendNotification(request: notifications_pb.ShouldSendNotificationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.ShouldSendNotificationResponse) => void): grpc.ClientUnaryCall; + userEnableNotificationChannel(request: notifications_pb.UserEnableNotificationChannelRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + userEnableNotificationChannel(request: notifications_pb.UserEnableNotificationChannelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + userEnableNotificationChannel(request: notifications_pb.UserEnableNotificationChannelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + userDisableNotificationChannel(request: notifications_pb.UserDisableNotificationChannelRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + userDisableNotificationChannel(request: notifications_pb.UserDisableNotificationChannelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + userDisableNotificationChannel(request: notifications_pb.UserDisableNotificationChannelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + userEnableNotificationCategory(request: notifications_pb.UserEnableNotificationCategoryRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + userEnableNotificationCategory(request: notifications_pb.UserEnableNotificationCategoryRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + userEnableNotificationCategory(request: notifications_pb.UserEnableNotificationCategoryRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + userDisableNotificationCategory(request: notifications_pb.UserDisableNotificationCategoryRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + userDisableNotificationCategory(request: notifications_pb.UserDisableNotificationCategoryRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + userDisableNotificationCategory(request: notifications_pb.UserDisableNotificationCategoryRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + userNotificationSettings(request: notifications_pb.UserNotificationSettingsRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserNotificationSettingsResponse) => void): grpc.ClientUnaryCall; + userNotificationSettings(request: notifications_pb.UserNotificationSettingsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserNotificationSettingsResponse) => void): grpc.ClientUnaryCall; + userNotificationSettings(request: notifications_pb.UserNotificationSettingsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserNotificationSettingsResponse) => void): grpc.ClientUnaryCall; +} + +export class NotificationsServiceClient extends grpc.Client implements INotificationsServiceClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); + public shouldSendNotification(request: notifications_pb.ShouldSendNotificationRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.ShouldSendNotificationResponse) => void): grpc.ClientUnaryCall; + public shouldSendNotification(request: notifications_pb.ShouldSendNotificationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.ShouldSendNotificationResponse) => void): grpc.ClientUnaryCall; + public shouldSendNotification(request: notifications_pb.ShouldSendNotificationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.ShouldSendNotificationResponse) => void): grpc.ClientUnaryCall; + public userEnableNotificationChannel(request: notifications_pb.UserEnableNotificationChannelRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + public userEnableNotificationChannel(request: notifications_pb.UserEnableNotificationChannelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + public userEnableNotificationChannel(request: notifications_pb.UserEnableNotificationChannelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + public userDisableNotificationChannel(request: notifications_pb.UserDisableNotificationChannelRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + public userDisableNotificationChannel(request: notifications_pb.UserDisableNotificationChannelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + public userDisableNotificationChannel(request: notifications_pb.UserDisableNotificationChannelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationChannelResponse) => void): grpc.ClientUnaryCall; + public userEnableNotificationCategory(request: notifications_pb.UserEnableNotificationCategoryRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + public userEnableNotificationCategory(request: notifications_pb.UserEnableNotificationCategoryRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + public userEnableNotificationCategory(request: notifications_pb.UserEnableNotificationCategoryRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserEnableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + public userDisableNotificationCategory(request: notifications_pb.UserDisableNotificationCategoryRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + public userDisableNotificationCategory(request: notifications_pb.UserDisableNotificationCategoryRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + public userDisableNotificationCategory(request: notifications_pb.UserDisableNotificationCategoryRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserDisableNotificationCategoryResponse) => void): grpc.ClientUnaryCall; + public userNotificationSettings(request: notifications_pb.UserNotificationSettingsRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserNotificationSettingsResponse) => void): grpc.ClientUnaryCall; + public userNotificationSettings(request: notifications_pb.UserNotificationSettingsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserNotificationSettingsResponse) => void): grpc.ClientUnaryCall; + public userNotificationSettings(request: notifications_pb.UserNotificationSettingsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UserNotificationSettingsResponse) => void): grpc.ClientUnaryCall; +} diff --git a/core/api/src/services/notifications/proto/notifications_grpc_pb.js b/core/api/src/services/notifications/proto/notifications_grpc_pb.js new file mode 100644 index 0000000000..8c2182b2d6 --- /dev/null +++ b/core/api/src/services/notifications/proto/notifications_grpc_pb.js @@ -0,0 +1,210 @@ +// GENERATED CODE -- DO NOT EDIT! + +'use strict'; +var grpc = require('@grpc/grpc-js'); +var notifications_pb = require('./notifications_pb.js'); +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js'); + +function serialize_services_notifications_v1_ShouldSendNotificationRequest(arg) { + if (!(arg instanceof notifications_pb.ShouldSendNotificationRequest)) { + throw new Error('Expected argument of type services.notifications.v1.ShouldSendNotificationRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_ShouldSendNotificationRequest(buffer_arg) { + return notifications_pb.ShouldSendNotificationRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_ShouldSendNotificationResponse(arg) { + if (!(arg instanceof notifications_pb.ShouldSendNotificationResponse)) { + throw new Error('Expected argument of type services.notifications.v1.ShouldSendNotificationResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_ShouldSendNotificationResponse(buffer_arg) { + return notifications_pb.ShouldSendNotificationResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserDisableNotificationCategoryRequest(arg) { + if (!(arg instanceof notifications_pb.UserDisableNotificationCategoryRequest)) { + throw new Error('Expected argument of type services.notifications.v1.UserDisableNotificationCategoryRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserDisableNotificationCategoryRequest(buffer_arg) { + return notifications_pb.UserDisableNotificationCategoryRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserDisableNotificationCategoryResponse(arg) { + if (!(arg instanceof notifications_pb.UserDisableNotificationCategoryResponse)) { + throw new Error('Expected argument of type services.notifications.v1.UserDisableNotificationCategoryResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserDisableNotificationCategoryResponse(buffer_arg) { + return notifications_pb.UserDisableNotificationCategoryResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserDisableNotificationChannelRequest(arg) { + if (!(arg instanceof notifications_pb.UserDisableNotificationChannelRequest)) { + throw new Error('Expected argument of type services.notifications.v1.UserDisableNotificationChannelRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserDisableNotificationChannelRequest(buffer_arg) { + return notifications_pb.UserDisableNotificationChannelRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserDisableNotificationChannelResponse(arg) { + if (!(arg instanceof notifications_pb.UserDisableNotificationChannelResponse)) { + throw new Error('Expected argument of type services.notifications.v1.UserDisableNotificationChannelResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserDisableNotificationChannelResponse(buffer_arg) { + return notifications_pb.UserDisableNotificationChannelResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserEnableNotificationCategoryRequest(arg) { + if (!(arg instanceof notifications_pb.UserEnableNotificationCategoryRequest)) { + throw new Error('Expected argument of type services.notifications.v1.UserEnableNotificationCategoryRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserEnableNotificationCategoryRequest(buffer_arg) { + return notifications_pb.UserEnableNotificationCategoryRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserEnableNotificationCategoryResponse(arg) { + if (!(arg instanceof notifications_pb.UserEnableNotificationCategoryResponse)) { + throw new Error('Expected argument of type services.notifications.v1.UserEnableNotificationCategoryResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserEnableNotificationCategoryResponse(buffer_arg) { + return notifications_pb.UserEnableNotificationCategoryResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserEnableNotificationChannelRequest(arg) { + if (!(arg instanceof notifications_pb.UserEnableNotificationChannelRequest)) { + throw new Error('Expected argument of type services.notifications.v1.UserEnableNotificationChannelRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserEnableNotificationChannelRequest(buffer_arg) { + return notifications_pb.UserEnableNotificationChannelRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserEnableNotificationChannelResponse(arg) { + if (!(arg instanceof notifications_pb.UserEnableNotificationChannelResponse)) { + throw new Error('Expected argument of type services.notifications.v1.UserEnableNotificationChannelResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserEnableNotificationChannelResponse(buffer_arg) { + return notifications_pb.UserEnableNotificationChannelResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserNotificationSettingsRequest(arg) { + if (!(arg instanceof notifications_pb.UserNotificationSettingsRequest)) { + throw new Error('Expected argument of type services.notifications.v1.UserNotificationSettingsRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserNotificationSettingsRequest(buffer_arg) { + return notifications_pb.UserNotificationSettingsRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UserNotificationSettingsResponse(arg) { + if (!(arg instanceof notifications_pb.UserNotificationSettingsResponse)) { + throw new Error('Expected argument of type services.notifications.v1.UserNotificationSettingsResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UserNotificationSettingsResponse(buffer_arg) { + return notifications_pb.UserNotificationSettingsResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var NotificationsServiceService = exports.NotificationsServiceService = { + shouldSendNotification: { + path: '/services.notifications.v1.NotificationsService/ShouldSendNotification', + requestStream: false, + responseStream: false, + requestType: notifications_pb.ShouldSendNotificationRequest, + responseType: notifications_pb.ShouldSendNotificationResponse, + requestSerialize: serialize_services_notifications_v1_ShouldSendNotificationRequest, + requestDeserialize: deserialize_services_notifications_v1_ShouldSendNotificationRequest, + responseSerialize: serialize_services_notifications_v1_ShouldSendNotificationResponse, + responseDeserialize: deserialize_services_notifications_v1_ShouldSendNotificationResponse, + }, + userEnableNotificationChannel: { + path: '/services.notifications.v1.NotificationsService/UserEnableNotificationChannel', + requestStream: false, + responseStream: false, + requestType: notifications_pb.UserEnableNotificationChannelRequest, + responseType: notifications_pb.UserEnableNotificationChannelResponse, + requestSerialize: serialize_services_notifications_v1_UserEnableNotificationChannelRequest, + requestDeserialize: deserialize_services_notifications_v1_UserEnableNotificationChannelRequest, + responseSerialize: serialize_services_notifications_v1_UserEnableNotificationChannelResponse, + responseDeserialize: deserialize_services_notifications_v1_UserEnableNotificationChannelResponse, + }, + userDisableNotificationChannel: { + path: '/services.notifications.v1.NotificationsService/UserDisableNotificationChannel', + requestStream: false, + responseStream: false, + requestType: notifications_pb.UserDisableNotificationChannelRequest, + responseType: notifications_pb.UserDisableNotificationChannelResponse, + requestSerialize: serialize_services_notifications_v1_UserDisableNotificationChannelRequest, + requestDeserialize: deserialize_services_notifications_v1_UserDisableNotificationChannelRequest, + responseSerialize: serialize_services_notifications_v1_UserDisableNotificationChannelResponse, + responseDeserialize: deserialize_services_notifications_v1_UserDisableNotificationChannelResponse, + }, + userEnableNotificationCategory: { + path: '/services.notifications.v1.NotificationsService/UserEnableNotificationCategory', + requestStream: false, + responseStream: false, + requestType: notifications_pb.UserEnableNotificationCategoryRequest, + responseType: notifications_pb.UserEnableNotificationCategoryResponse, + requestSerialize: serialize_services_notifications_v1_UserEnableNotificationCategoryRequest, + requestDeserialize: deserialize_services_notifications_v1_UserEnableNotificationCategoryRequest, + responseSerialize: serialize_services_notifications_v1_UserEnableNotificationCategoryResponse, + responseDeserialize: deserialize_services_notifications_v1_UserEnableNotificationCategoryResponse, + }, + userDisableNotificationCategory: { + path: '/services.notifications.v1.NotificationsService/UserDisableNotificationCategory', + requestStream: false, + responseStream: false, + requestType: notifications_pb.UserDisableNotificationCategoryRequest, + responseType: notifications_pb.UserDisableNotificationCategoryResponse, + requestSerialize: serialize_services_notifications_v1_UserDisableNotificationCategoryRequest, + requestDeserialize: deserialize_services_notifications_v1_UserDisableNotificationCategoryRequest, + responseSerialize: serialize_services_notifications_v1_UserDisableNotificationCategoryResponse, + responseDeserialize: deserialize_services_notifications_v1_UserDisableNotificationCategoryResponse, + }, + userNotificationSettings: { + path: '/services.notifications.v1.NotificationsService/UserNotificationSettings', + requestStream: false, + responseStream: false, + requestType: notifications_pb.UserNotificationSettingsRequest, + responseType: notifications_pb.UserNotificationSettingsResponse, + requestSerialize: serialize_services_notifications_v1_UserNotificationSettingsRequest, + requestDeserialize: deserialize_services_notifications_v1_UserNotificationSettingsRequest, + responseSerialize: serialize_services_notifications_v1_UserNotificationSettingsResponse, + responseDeserialize: deserialize_services_notifications_v1_UserNotificationSettingsResponse, + }, +}; + +exports.NotificationsServiceClient = grpc.makeGenericClientConstructor(NotificationsServiceService); diff --git a/core/api/src/services/notifications/proto/notifications_pb.d.ts b/core/api/src/services/notifications/proto/notifications_pb.d.ts new file mode 100644 index 0000000000..7e53084a73 --- /dev/null +++ b/core/api/src/services/notifications/proto/notifications_pb.d.ts @@ -0,0 +1,347 @@ +// package: services.notifications.v1 +// file: notifications.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb"; + +export class ShouldSendNotificationRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): ShouldSendNotificationRequest; + getChannel(): NotificationChannel; + setChannel(value: NotificationChannel): ShouldSendNotificationRequest; + getCategory(): NotificationCategory; + setCategory(value: NotificationCategory): ShouldSendNotificationRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ShouldSendNotificationRequest.AsObject; + static toObject(includeInstance: boolean, msg: ShouldSendNotificationRequest): ShouldSendNotificationRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ShouldSendNotificationRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ShouldSendNotificationRequest; + static deserializeBinaryFromReader(message: ShouldSendNotificationRequest, reader: jspb.BinaryReader): ShouldSendNotificationRequest; +} + +export namespace ShouldSendNotificationRequest { + export type AsObject = { + userId: string, + channel: NotificationChannel, + category: NotificationCategory, + } +} + +export class ShouldSendNotificationResponse extends jspb.Message { + getUserId(): string; + setUserId(value: string): ShouldSendNotificationResponse; + getShouldSend(): boolean; + setShouldSend(value: boolean): ShouldSendNotificationResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ShouldSendNotificationResponse.AsObject; + static toObject(includeInstance: boolean, msg: ShouldSendNotificationResponse): ShouldSendNotificationResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ShouldSendNotificationResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ShouldSendNotificationResponse; + static deserializeBinaryFromReader(message: ShouldSendNotificationResponse, reader: jspb.BinaryReader): ShouldSendNotificationResponse; +} + +export namespace ShouldSendNotificationResponse { + export type AsObject = { + userId: string, + shouldSend: boolean, + } +} + +export class UserEnableNotificationChannelRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): UserEnableNotificationChannelRequest; + getChannel(): NotificationChannel; + setChannel(value: NotificationChannel): UserEnableNotificationChannelRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserEnableNotificationChannelRequest.AsObject; + static toObject(includeInstance: boolean, msg: UserEnableNotificationChannelRequest): UserEnableNotificationChannelRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserEnableNotificationChannelRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserEnableNotificationChannelRequest; + static deserializeBinaryFromReader(message: UserEnableNotificationChannelRequest, reader: jspb.BinaryReader): UserEnableNotificationChannelRequest; +} + +export namespace UserEnableNotificationChannelRequest { + export type AsObject = { + userId: string, + channel: NotificationChannel, + } +} + +export class UserEnableNotificationChannelResponse extends jspb.Message { + + hasNotificationSettings(): boolean; + clearNotificationSettings(): void; + getNotificationSettings(): UserNotificationSettings | undefined; + setNotificationSettings(value?: UserNotificationSettings): UserEnableNotificationChannelResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserEnableNotificationChannelResponse.AsObject; + static toObject(includeInstance: boolean, msg: UserEnableNotificationChannelResponse): UserEnableNotificationChannelResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserEnableNotificationChannelResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserEnableNotificationChannelResponse; + static deserializeBinaryFromReader(message: UserEnableNotificationChannelResponse, reader: jspb.BinaryReader): UserEnableNotificationChannelResponse; +} + +export namespace UserEnableNotificationChannelResponse { + export type AsObject = { + notificationSettings?: UserNotificationSettings.AsObject, + } +} + +export class UserNotificationSettings extends jspb.Message { + + hasPush(): boolean; + clearPush(): void; + getPush(): ChannelNotificationSettings | undefined; + setPush(value?: ChannelNotificationSettings): UserNotificationSettings; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserNotificationSettings.AsObject; + static toObject(includeInstance: boolean, msg: UserNotificationSettings): UserNotificationSettings.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserNotificationSettings, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserNotificationSettings; + static deserializeBinaryFromReader(message: UserNotificationSettings, reader: jspb.BinaryReader): UserNotificationSettings; +} + +export namespace UserNotificationSettings { + export type AsObject = { + push?: ChannelNotificationSettings.AsObject, + } +} + +export class ChannelNotificationSettings extends jspb.Message { + getEnabled(): boolean; + setEnabled(value: boolean): ChannelNotificationSettings; + clearDisabledCategoriesList(): void; + getDisabledCategoriesList(): Array; + setDisabledCategoriesList(value: Array): ChannelNotificationSettings; + addDisabledCategories(value: NotificationCategory, index?: number): NotificationCategory; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ChannelNotificationSettings.AsObject; + static toObject(includeInstance: boolean, msg: ChannelNotificationSettings): ChannelNotificationSettings.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ChannelNotificationSettings, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ChannelNotificationSettings; + static deserializeBinaryFromReader(message: ChannelNotificationSettings, reader: jspb.BinaryReader): ChannelNotificationSettings; +} + +export namespace ChannelNotificationSettings { + export type AsObject = { + enabled: boolean, + disabledCategoriesList: Array, + } +} + +export class UserDisableNotificationChannelRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): UserDisableNotificationChannelRequest; + getChannel(): NotificationChannel; + setChannel(value: NotificationChannel): UserDisableNotificationChannelRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserDisableNotificationChannelRequest.AsObject; + static toObject(includeInstance: boolean, msg: UserDisableNotificationChannelRequest): UserDisableNotificationChannelRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserDisableNotificationChannelRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserDisableNotificationChannelRequest; + static deserializeBinaryFromReader(message: UserDisableNotificationChannelRequest, reader: jspb.BinaryReader): UserDisableNotificationChannelRequest; +} + +export namespace UserDisableNotificationChannelRequest { + export type AsObject = { + userId: string, + channel: NotificationChannel, + } +} + +export class UserDisableNotificationChannelResponse extends jspb.Message { + + hasNotificationSettings(): boolean; + clearNotificationSettings(): void; + getNotificationSettings(): UserNotificationSettings | undefined; + setNotificationSettings(value?: UserNotificationSettings): UserDisableNotificationChannelResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserDisableNotificationChannelResponse.AsObject; + static toObject(includeInstance: boolean, msg: UserDisableNotificationChannelResponse): UserDisableNotificationChannelResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserDisableNotificationChannelResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserDisableNotificationChannelResponse; + static deserializeBinaryFromReader(message: UserDisableNotificationChannelResponse, reader: jspb.BinaryReader): UserDisableNotificationChannelResponse; +} + +export namespace UserDisableNotificationChannelResponse { + export type AsObject = { + notificationSettings?: UserNotificationSettings.AsObject, + } +} + +export class UserDisableNotificationCategoryRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): UserDisableNotificationCategoryRequest; + getChannel(): NotificationChannel; + setChannel(value: NotificationChannel): UserDisableNotificationCategoryRequest; + getCategory(): NotificationCategory; + setCategory(value: NotificationCategory): UserDisableNotificationCategoryRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserDisableNotificationCategoryRequest.AsObject; + static toObject(includeInstance: boolean, msg: UserDisableNotificationCategoryRequest): UserDisableNotificationCategoryRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserDisableNotificationCategoryRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserDisableNotificationCategoryRequest; + static deserializeBinaryFromReader(message: UserDisableNotificationCategoryRequest, reader: jspb.BinaryReader): UserDisableNotificationCategoryRequest; +} + +export namespace UserDisableNotificationCategoryRequest { + export type AsObject = { + userId: string, + channel: NotificationChannel, + category: NotificationCategory, + } +} + +export class UserDisableNotificationCategoryResponse extends jspb.Message { + + hasNotificationSettings(): boolean; + clearNotificationSettings(): void; + getNotificationSettings(): UserNotificationSettings | undefined; + setNotificationSettings(value?: UserNotificationSettings): UserDisableNotificationCategoryResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserDisableNotificationCategoryResponse.AsObject; + static toObject(includeInstance: boolean, msg: UserDisableNotificationCategoryResponse): UserDisableNotificationCategoryResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserDisableNotificationCategoryResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserDisableNotificationCategoryResponse; + static deserializeBinaryFromReader(message: UserDisableNotificationCategoryResponse, reader: jspb.BinaryReader): UserDisableNotificationCategoryResponse; +} + +export namespace UserDisableNotificationCategoryResponse { + export type AsObject = { + notificationSettings?: UserNotificationSettings.AsObject, + } +} + +export class UserEnableNotificationCategoryRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): UserEnableNotificationCategoryRequest; + getChannel(): NotificationChannel; + setChannel(value: NotificationChannel): UserEnableNotificationCategoryRequest; + getCategory(): NotificationCategory; + setCategory(value: NotificationCategory): UserEnableNotificationCategoryRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserEnableNotificationCategoryRequest.AsObject; + static toObject(includeInstance: boolean, msg: UserEnableNotificationCategoryRequest): UserEnableNotificationCategoryRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserEnableNotificationCategoryRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserEnableNotificationCategoryRequest; + static deserializeBinaryFromReader(message: UserEnableNotificationCategoryRequest, reader: jspb.BinaryReader): UserEnableNotificationCategoryRequest; +} + +export namespace UserEnableNotificationCategoryRequest { + export type AsObject = { + userId: string, + channel: NotificationChannel, + category: NotificationCategory, + } +} + +export class UserEnableNotificationCategoryResponse extends jspb.Message { + + hasNotificationSettings(): boolean; + clearNotificationSettings(): void; + getNotificationSettings(): UserNotificationSettings | undefined; + setNotificationSettings(value?: UserNotificationSettings): UserEnableNotificationCategoryResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserEnableNotificationCategoryResponse.AsObject; + static toObject(includeInstance: boolean, msg: UserEnableNotificationCategoryResponse): UserEnableNotificationCategoryResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserEnableNotificationCategoryResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserEnableNotificationCategoryResponse; + static deserializeBinaryFromReader(message: UserEnableNotificationCategoryResponse, reader: jspb.BinaryReader): UserEnableNotificationCategoryResponse; +} + +export namespace UserEnableNotificationCategoryResponse { + export type AsObject = { + notificationSettings?: UserNotificationSettings.AsObject, + } +} + +export class UserNotificationSettingsRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): UserNotificationSettingsRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserNotificationSettingsRequest.AsObject; + static toObject(includeInstance: boolean, msg: UserNotificationSettingsRequest): UserNotificationSettingsRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserNotificationSettingsRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserNotificationSettingsRequest; + static deserializeBinaryFromReader(message: UserNotificationSettingsRequest, reader: jspb.BinaryReader): UserNotificationSettingsRequest; +} + +export namespace UserNotificationSettingsRequest { + export type AsObject = { + userId: string, + } +} + +export class UserNotificationSettingsResponse extends jspb.Message { + + hasNotificationSettings(): boolean; + clearNotificationSettings(): void; + getNotificationSettings(): UserNotificationSettings | undefined; + setNotificationSettings(value?: UserNotificationSettings): UserNotificationSettingsResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserNotificationSettingsResponse.AsObject; + static toObject(includeInstance: boolean, msg: UserNotificationSettingsResponse): UserNotificationSettingsResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserNotificationSettingsResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserNotificationSettingsResponse; + static deserializeBinaryFromReader(message: UserNotificationSettingsResponse, reader: jspb.BinaryReader): UserNotificationSettingsResponse; +} + +export namespace UserNotificationSettingsResponse { + export type AsObject = { + notificationSettings?: UserNotificationSettings.AsObject, + } +} + +export enum NotificationChannel { + PUSH = 0, +} + +export enum NotificationCategory { + CIRCLES = 0, + PAYMENTS = 1, +} diff --git a/core/api/src/services/notifications/proto/notifications_pb.js b/core/api/src/services/notifications/proto/notifications_pb.js new file mode 100644 index 0000000000..49fe867193 --- /dev/null +++ b/core/api/src/services/notifications/proto/notifications_pb.js @@ -0,0 +1,2625 @@ +// source: notifications.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); + +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js'); +goog.object.extend(proto, google_protobuf_struct_pb); +goog.exportSymbol('proto.services.notifications.v1.ChannelNotificationSettings', null, global); +goog.exportSymbol('proto.services.notifications.v1.NotificationCategory', null, global); +goog.exportSymbol('proto.services.notifications.v1.NotificationChannel', null, global); +goog.exportSymbol('proto.services.notifications.v1.ShouldSendNotificationRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.ShouldSendNotificationResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserDisableNotificationCategoryRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserDisableNotificationCategoryResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserDisableNotificationChannelRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserDisableNotificationChannelResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserEnableNotificationCategoryRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserEnableNotificationCategoryResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserEnableNotificationChannelRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserEnableNotificationChannelResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserNotificationSettings', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserNotificationSettingsRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.UserNotificationSettingsResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.ShouldSendNotificationRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.ShouldSendNotificationRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.ShouldSendNotificationRequest.displayName = 'proto.services.notifications.v1.ShouldSendNotificationRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.ShouldSendNotificationResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.ShouldSendNotificationResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.ShouldSendNotificationResponse.displayName = 'proto.services.notifications.v1.ShouldSendNotificationResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserEnableNotificationChannelRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserEnableNotificationChannelRequest.displayName = 'proto.services.notifications.v1.UserEnableNotificationChannelRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserEnableNotificationChannelResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserEnableNotificationChannelResponse.displayName = 'proto.services.notifications.v1.UserEnableNotificationChannelResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserNotificationSettings = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserNotificationSettings, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserNotificationSettings.displayName = 'proto.services.notifications.v1.UserNotificationSettings'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.ChannelNotificationSettings = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.services.notifications.v1.ChannelNotificationSettings.repeatedFields_, null); +}; +goog.inherits(proto.services.notifications.v1.ChannelNotificationSettings, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.ChannelNotificationSettings.displayName = 'proto.services.notifications.v1.ChannelNotificationSettings'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserDisableNotificationChannelRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserDisableNotificationChannelRequest.displayName = 'proto.services.notifications.v1.UserDisableNotificationChannelRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserDisableNotificationChannelResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserDisableNotificationChannelResponse.displayName = 'proto.services.notifications.v1.UserDisableNotificationChannelResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserDisableNotificationCategoryRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserDisableNotificationCategoryRequest.displayName = 'proto.services.notifications.v1.UserDisableNotificationCategoryRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserDisableNotificationCategoryResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserDisableNotificationCategoryResponse.displayName = 'proto.services.notifications.v1.UserDisableNotificationCategoryResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserEnableNotificationCategoryRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserEnableNotificationCategoryRequest.displayName = 'proto.services.notifications.v1.UserEnableNotificationCategoryRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserEnableNotificationCategoryResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserEnableNotificationCategoryResponse.displayName = 'proto.services.notifications.v1.UserEnableNotificationCategoryResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserNotificationSettingsRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserNotificationSettingsRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserNotificationSettingsRequest.displayName = 'proto.services.notifications.v1.UserNotificationSettingsRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.services.notifications.v1.UserNotificationSettingsResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UserNotificationSettingsResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UserNotificationSettingsResponse.displayName = 'proto.services.notifications.v1.UserNotificationSettingsResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.ShouldSendNotificationRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.ShouldSendNotificationRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + channel: jspb.Message.getFieldWithDefault(msg, 2, 0), + category: jspb.Message.getFieldWithDefault(msg, 3, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.ShouldSendNotificationRequest} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.ShouldSendNotificationRequest; + return proto.services.notifications.v1.ShouldSendNotificationRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.ShouldSendNotificationRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.ShouldSendNotificationRequest} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + case 2: + var value = /** @type {!proto.services.notifications.v1.NotificationChannel} */ (reader.readEnum()); + msg.setChannel(value); + break; + case 3: + var value = /** @type {!proto.services.notifications.v1.NotificationCategory} */ (reader.readEnum()); + msg.setCategory(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.ShouldSendNotificationRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.ShouldSendNotificationRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getChannel(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getCategory(); + if (f !== 0.0) { + writer.writeEnum( + 3, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.ShouldSendNotificationRequest} returns this + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional NotificationChannel channel = 2; + * @return {!proto.services.notifications.v1.NotificationChannel} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.getChannel = function() { + return /** @type {!proto.services.notifications.v1.NotificationChannel} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationChannel} value + * @return {!proto.services.notifications.v1.ShouldSendNotificationRequest} returns this + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.setChannel = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional NotificationCategory category = 3; + * @return {!proto.services.notifications.v1.NotificationCategory} + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.getCategory = function() { + return /** @type {!proto.services.notifications.v1.NotificationCategory} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationCategory} value + * @return {!proto.services.notifications.v1.ShouldSendNotificationRequest} returns this + */ +proto.services.notifications.v1.ShouldSendNotificationRequest.prototype.setCategory = function(value) { + return jspb.Message.setProto3EnumField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.ShouldSendNotificationResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.ShouldSendNotificationResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + shouldSend: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.ShouldSendNotificationResponse} + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.ShouldSendNotificationResponse; + return proto.services.notifications.v1.ShouldSendNotificationResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.ShouldSendNotificationResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.ShouldSendNotificationResponse} + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setShouldSend(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.ShouldSendNotificationResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.ShouldSendNotificationResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getShouldSend(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.ShouldSendNotificationResponse} returns this + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional bool should_send = 2; + * @return {boolean} + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.prototype.getShouldSend = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.services.notifications.v1.ShouldSendNotificationResponse} returns this + */ +proto.services.notifications.v1.ShouldSendNotificationResponse.prototype.setShouldSend = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserEnableNotificationChannelRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + channel: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserEnableNotificationChannelRequest; + return proto.services.notifications.v1.UserEnableNotificationChannelRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + case 2: + var value = /** @type {!proto.services.notifications.v1.NotificationChannel} */ (reader.readEnum()); + msg.setChannel(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserEnableNotificationChannelRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getChannel(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} returns this + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional NotificationChannel channel = 2; + * @return {!proto.services.notifications.v1.NotificationChannel} + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.prototype.getChannel = function() { + return /** @type {!proto.services.notifications.v1.NotificationChannel} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationChannel} value + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelRequest} returns this + */ +proto.services.notifications.v1.UserEnableNotificationChannelRequest.prototype.setChannel = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserEnableNotificationChannelResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.toObject = function(includeInstance, msg) { + var f, obj = { + notificationSettings: (f = msg.getNotificationSettings()) && proto.services.notifications.v1.UserNotificationSettings.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserEnableNotificationChannelResponse; + return proto.services.notifications.v1.UserEnableNotificationChannelResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.services.notifications.v1.UserNotificationSettings; + reader.readMessage(value,proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader); + msg.setNotificationSettings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserEnableNotificationChannelResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNotificationSettings(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter + ); + } +}; + + +/** + * optional UserNotificationSettings notification_settings = 1; + * @return {?proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.prototype.getNotificationSettings = function() { + return /** @type{?proto.services.notifications.v1.UserNotificationSettings} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.UserNotificationSettings, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.UserNotificationSettings|undefined} value + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} returns this +*/ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.prototype.setNotificationSettings = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.UserEnableNotificationChannelResponse} returns this + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.prototype.clearNotificationSettings = function() { + return this.setNotificationSettings(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.UserEnableNotificationChannelResponse.prototype.hasNotificationSettings = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserNotificationSettings.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserNotificationSettings.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserNotificationSettings} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserNotificationSettings.toObject = function(includeInstance, msg) { + var f, obj = { + push: (f = msg.getPush()) && proto.services.notifications.v1.ChannelNotificationSettings.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserNotificationSettings.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserNotificationSettings; + return proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserNotificationSettings} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.services.notifications.v1.ChannelNotificationSettings; + reader.readMessage(value,proto.services.notifications.v1.ChannelNotificationSettings.deserializeBinaryFromReader); + msg.setPush(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserNotificationSettings.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserNotificationSettings} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPush(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.ChannelNotificationSettings.serializeBinaryToWriter + ); + } +}; + + +/** + * optional ChannelNotificationSettings push = 1; + * @return {?proto.services.notifications.v1.ChannelNotificationSettings} + */ +proto.services.notifications.v1.UserNotificationSettings.prototype.getPush = function() { + return /** @type{?proto.services.notifications.v1.ChannelNotificationSettings} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.ChannelNotificationSettings, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.ChannelNotificationSettings|undefined} value + * @return {!proto.services.notifications.v1.UserNotificationSettings} returns this +*/ +proto.services.notifications.v1.UserNotificationSettings.prototype.setPush = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.UserNotificationSettings} returns this + */ +proto.services.notifications.v1.UserNotificationSettings.prototype.clearPush = function() { + return this.setPush(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.UserNotificationSettings.prototype.hasPush = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.services.notifications.v1.ChannelNotificationSettings.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.ChannelNotificationSettings.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.ChannelNotificationSettings} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.ChannelNotificationSettings.toObject = function(includeInstance, msg) { + var f, obj = { + enabled: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + disabledCategoriesList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.ChannelNotificationSettings} + */ +proto.services.notifications.v1.ChannelNotificationSettings.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.ChannelNotificationSettings; + return proto.services.notifications.v1.ChannelNotificationSettings.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.ChannelNotificationSettings} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.ChannelNotificationSettings} + */ +proto.services.notifications.v1.ChannelNotificationSettings.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setEnabled(value); + break; + case 2: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]); + for (var i = 0; i < values.length; i++) { + msg.addDisabledCategories(values[i]); + } + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.ChannelNotificationSettings.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.ChannelNotificationSettings} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.ChannelNotificationSettings.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getEnabled(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getDisabledCategoriesList(); + if (f.length > 0) { + writer.writePackedEnum( + 2, + f + ); + } +}; + + +/** + * optional bool enabled = 1; + * @return {boolean} + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.getEnabled = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.services.notifications.v1.ChannelNotificationSettings} returns this + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.setEnabled = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated NotificationCategory disabled_categories = 2; + * @return {!Array} + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.getDisabledCategoriesList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.services.notifications.v1.ChannelNotificationSettings} returns this + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.setDisabledCategoriesList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationCategory} value + * @param {number=} opt_index + * @return {!proto.services.notifications.v1.ChannelNotificationSettings} returns this + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.addDisabledCategories = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.services.notifications.v1.ChannelNotificationSettings} returns this + */ +proto.services.notifications.v1.ChannelNotificationSettings.prototype.clearDisabledCategoriesList = function() { + return this.setDisabledCategoriesList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserDisableNotificationChannelRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + channel: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserDisableNotificationChannelRequest; + return proto.services.notifications.v1.UserDisableNotificationChannelRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + case 2: + var value = /** @type {!proto.services.notifications.v1.NotificationChannel} */ (reader.readEnum()); + msg.setChannel(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserDisableNotificationChannelRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getChannel(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} returns this + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional NotificationChannel channel = 2; + * @return {!proto.services.notifications.v1.NotificationChannel} + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.prototype.getChannel = function() { + return /** @type {!proto.services.notifications.v1.NotificationChannel} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationChannel} value + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelRequest} returns this + */ +proto.services.notifications.v1.UserDisableNotificationChannelRequest.prototype.setChannel = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserDisableNotificationChannelResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.toObject = function(includeInstance, msg) { + var f, obj = { + notificationSettings: (f = msg.getNotificationSettings()) && proto.services.notifications.v1.UserNotificationSettings.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserDisableNotificationChannelResponse; + return proto.services.notifications.v1.UserDisableNotificationChannelResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.services.notifications.v1.UserNotificationSettings; + reader.readMessage(value,proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader); + msg.setNotificationSettings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserDisableNotificationChannelResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNotificationSettings(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter + ); + } +}; + + +/** + * optional UserNotificationSettings notification_settings = 1; + * @return {?proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.prototype.getNotificationSettings = function() { + return /** @type{?proto.services.notifications.v1.UserNotificationSettings} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.UserNotificationSettings, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.UserNotificationSettings|undefined} value + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} returns this +*/ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.prototype.setNotificationSettings = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.UserDisableNotificationChannelResponse} returns this + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.prototype.clearNotificationSettings = function() { + return this.setNotificationSettings(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.UserDisableNotificationChannelResponse.prototype.hasNotificationSettings = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserDisableNotificationCategoryRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + channel: jspb.Message.getFieldWithDefault(msg, 2, 0), + category: jspb.Message.getFieldWithDefault(msg, 3, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserDisableNotificationCategoryRequest; + return proto.services.notifications.v1.UserDisableNotificationCategoryRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + case 2: + var value = /** @type {!proto.services.notifications.v1.NotificationChannel} */ (reader.readEnum()); + msg.setChannel(value); + break; + case 3: + var value = /** @type {!proto.services.notifications.v1.NotificationCategory} */ (reader.readEnum()); + msg.setCategory(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserDisableNotificationCategoryRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getChannel(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getCategory(); + if (f !== 0.0) { + writer.writeEnum( + 3, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} returns this + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional NotificationChannel channel = 2; + * @return {!proto.services.notifications.v1.NotificationChannel} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.getChannel = function() { + return /** @type {!proto.services.notifications.v1.NotificationChannel} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationChannel} value + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} returns this + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.setChannel = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional NotificationCategory category = 3; + * @return {!proto.services.notifications.v1.NotificationCategory} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.getCategory = function() { + return /** @type {!proto.services.notifications.v1.NotificationCategory} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationCategory} value + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryRequest} returns this + */ +proto.services.notifications.v1.UserDisableNotificationCategoryRequest.prototype.setCategory = function(value) { + return jspb.Message.setProto3EnumField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserDisableNotificationCategoryResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.toObject = function(includeInstance, msg) { + var f, obj = { + notificationSettings: (f = msg.getNotificationSettings()) && proto.services.notifications.v1.UserNotificationSettings.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserDisableNotificationCategoryResponse; + return proto.services.notifications.v1.UserDisableNotificationCategoryResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.services.notifications.v1.UserNotificationSettings; + reader.readMessage(value,proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader); + msg.setNotificationSettings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserDisableNotificationCategoryResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNotificationSettings(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter + ); + } +}; + + +/** + * optional UserNotificationSettings notification_settings = 1; + * @return {?proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.prototype.getNotificationSettings = function() { + return /** @type{?proto.services.notifications.v1.UserNotificationSettings} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.UserNotificationSettings, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.UserNotificationSettings|undefined} value + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} returns this +*/ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.prototype.setNotificationSettings = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.UserDisableNotificationCategoryResponse} returns this + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.prototype.clearNotificationSettings = function() { + return this.setNotificationSettings(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.UserDisableNotificationCategoryResponse.prototype.hasNotificationSettings = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserEnableNotificationCategoryRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + channel: jspb.Message.getFieldWithDefault(msg, 2, 0), + category: jspb.Message.getFieldWithDefault(msg, 3, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserEnableNotificationCategoryRequest; + return proto.services.notifications.v1.UserEnableNotificationCategoryRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + case 2: + var value = /** @type {!proto.services.notifications.v1.NotificationChannel} */ (reader.readEnum()); + msg.setChannel(value); + break; + case 3: + var value = /** @type {!proto.services.notifications.v1.NotificationCategory} */ (reader.readEnum()); + msg.setCategory(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserEnableNotificationCategoryRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getChannel(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getCategory(); + if (f !== 0.0) { + writer.writeEnum( + 3, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} returns this + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional NotificationChannel channel = 2; + * @return {!proto.services.notifications.v1.NotificationChannel} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.getChannel = function() { + return /** @type {!proto.services.notifications.v1.NotificationChannel} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationChannel} value + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} returns this + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.setChannel = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional NotificationCategory category = 3; + * @return {!proto.services.notifications.v1.NotificationCategory} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.getCategory = function() { + return /** @type {!proto.services.notifications.v1.NotificationCategory} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.NotificationCategory} value + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryRequest} returns this + */ +proto.services.notifications.v1.UserEnableNotificationCategoryRequest.prototype.setCategory = function(value) { + return jspb.Message.setProto3EnumField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserEnableNotificationCategoryResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.toObject = function(includeInstance, msg) { + var f, obj = { + notificationSettings: (f = msg.getNotificationSettings()) && proto.services.notifications.v1.UserNotificationSettings.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserEnableNotificationCategoryResponse; + return proto.services.notifications.v1.UserEnableNotificationCategoryResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.services.notifications.v1.UserNotificationSettings; + reader.readMessage(value,proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader); + msg.setNotificationSettings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserEnableNotificationCategoryResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNotificationSettings(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter + ); + } +}; + + +/** + * optional UserNotificationSettings notification_settings = 1; + * @return {?proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.prototype.getNotificationSettings = function() { + return /** @type{?proto.services.notifications.v1.UserNotificationSettings} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.UserNotificationSettings, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.UserNotificationSettings|undefined} value + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} returns this +*/ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.prototype.setNotificationSettings = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.UserEnableNotificationCategoryResponse} returns this + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.prototype.clearNotificationSettings = function() { + return this.setNotificationSettings(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.UserEnableNotificationCategoryResponse.prototype.hasNotificationSettings = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserNotificationSettingsRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserNotificationSettingsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserNotificationSettingsRequest} + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserNotificationSettingsRequest; + return proto.services.notifications.v1.UserNotificationSettingsRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserNotificationSettingsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserNotificationSettingsRequest} + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserNotificationSettingsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserNotificationSettingsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UserNotificationSettingsRequest} returns this + */ +proto.services.notifications.v1.UserNotificationSettingsRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UserNotificationSettingsResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.services.notifications.v1.UserNotificationSettingsResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.toObject = function(includeInstance, msg) { + var f, obj = { + notificationSettings: (f = msg.getNotificationSettings()) && proto.services.notifications.v1.UserNotificationSettings.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.services.notifications.v1.UserNotificationSettingsResponse} + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UserNotificationSettingsResponse; + return proto.services.notifications.v1.UserNotificationSettingsResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UserNotificationSettingsResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UserNotificationSettingsResponse} + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.services.notifications.v1.UserNotificationSettings; + reader.readMessage(value,proto.services.notifications.v1.UserNotificationSettings.deserializeBinaryFromReader); + msg.setNotificationSettings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UserNotificationSettingsResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.services.notifications.v1.UserNotificationSettingsResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNotificationSettings(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.UserNotificationSettings.serializeBinaryToWriter + ); + } +}; + + +/** + * optional UserNotificationSettings notification_settings = 1; + * @return {?proto.services.notifications.v1.UserNotificationSettings} + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.prototype.getNotificationSettings = function() { + return /** @type{?proto.services.notifications.v1.UserNotificationSettings} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.UserNotificationSettings, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.UserNotificationSettings|undefined} value + * @return {!proto.services.notifications.v1.UserNotificationSettingsResponse} returns this +*/ +proto.services.notifications.v1.UserNotificationSettingsResponse.prototype.setNotificationSettings = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.UserNotificationSettingsResponse} returns this + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.prototype.clearNotificationSettings = function() { + return this.setNotificationSettings(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.UserNotificationSettingsResponse.prototype.hasNotificationSettings = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * @enum {number} + */ +proto.services.notifications.v1.NotificationChannel = { + PUSH: 0 +}; + +/** + * @enum {number} + */ +proto.services.notifications.v1.NotificationCategory = { + CIRCLES: 0, + PAYMENTS: 1 +}; + +goog.object.extend(exports, proto.services.notifications.v1); diff --git a/core/api/test/unit/domain/notifications/index.spec.ts b/core/api/test/unit/domain/notifications/index.spec.ts deleted file mode 100644 index b92ec82a31..0000000000 --- a/core/api/test/unit/domain/notifications/index.spec.ts +++ /dev/null @@ -1,172 +0,0 @@ -import { - NotificationChannel, - disableNotificationCategory, - enableNotificationChannel, - disableNotificationChannel, - shouldSendNotification, -} from "@/domain/notifications" - -describe("Notifications - push notification filtering", () => { - describe("shouldSendPushNotification", () => { - it("returns false when push notifications are disabled", () => { - const notificationSettings: NotificationSettings = { - push: { - enabled: false, - disabledCategories: [], - }, - } - - const notificationCategory = "transaction" as NotificationCategory - - expect( - shouldSendNotification({ - notificationSettings, - notificationCategory, - notificationChannel: NotificationChannel.Push, - }), - ).toBe(false) - }) - - it("returns true when a notification is not disabled", () => { - const notificationSettings: NotificationSettings = { - push: { - enabled: true, - disabledCategories: [], - }, - } - - const notificationCategory = "transaction" as NotificationCategory - - expect( - shouldSendNotification({ - notificationSettings, - notificationCategory, - notificationChannel: NotificationChannel.Push, - }), - ).toBe(true) - }) - - it("returns false when a notification is disabled", () => { - const notificationCategory = "transaction" as NotificationCategory - - const notificationSettings: NotificationSettings = { - push: { - enabled: true, - disabledCategories: [notificationCategory], - }, - } - - expect( - shouldSendNotification({ - notificationSettings, - notificationCategory, - notificationChannel: NotificationChannel.Push, - }), - ).toBe(false) - }) - }) - - describe("enableNotificationChannel", () => { - it("clears disabled categories when enabling a channel", () => { - const notificationSettings: NotificationSettings = { - push: { - enabled: false, - disabledCategories: ["transaction" as NotificationCategory], - }, - } - - const notificationChannel = NotificationChannel.Push - - const result = enableNotificationChannel({ - notificationSettings, - notificationChannel, - }) - - expect(result).toEqual({ - push: { - enabled: true, - disabledCategories: [], - }, - }) - }) - }) - - describe("disableNotificationChannel", () => { - it("clears disabled categories when disabling a channel", () => { - const notificationSettings: NotificationSettings = { - push: { - enabled: true, - disabledCategories: ["transaction" as NotificationCategory], - }, - } - - const notificationChannel = NotificationChannel.Push - - const result = disableNotificationChannel({ - notificationSettings, - notificationChannel, - }) - - expect(result).toEqual({ - push: { - enabled: false, - disabledCategories: [], - }, - }) - }) - }) - - describe("disableNotificationCategoryForChannel", () => { - it("adds a category to the disabled categories", () => { - const notificationSettings: NotificationSettings = { - push: { - enabled: true, - disabledCategories: [], - }, - } - - const notificationChannel = NotificationChannel.Push - - const notificationCategory = "transaction" as NotificationCategory - - const result = disableNotificationCategory({ - notificationSettings, - notificationChannel, - notificationCategory, - }) - - expect(result).toEqual({ - push: { - enabled: true, - disabledCategories: [notificationCategory], - }, - }) - }) - - it("does not add a category to the disabled categories if it is already there", () => { - const notificationCategory = "transaction" as NotificationCategory - - const notificationSettings: NotificationSettings = { - push: { - enabled: true, - disabledCategories: [notificationCategory], - }, - } - - const notificationChannel = NotificationChannel.Push - - const result = disableNotificationCategory({ - notificationSettings, - notificationChannel, - notificationCategory, - }) - - expect(result).toEqual({ - push: { - enabled: true, - disabledCategories: [notificationCategory], - }, - }) - }) - }) -}) diff --git a/dev/Tiltfile b/dev/Tiltfile index 35c97d9665..2c6a2f9095 100644 --- a/dev/Tiltfile +++ b/dev/Tiltfile @@ -220,6 +220,7 @@ core_serve_env = { "PRICE_HISTORY_HOST": "localhost", "BRIA_HOST": "localhost", "BRIA_API_KEY": "bria_dev_000000000000000000000", + "NOTIFICATIONS_HOST": "localhost", "MONGODB_CON": "mongodb://localhost:27017/galoy", "REDIS_MASTER_NAME": "mymaster", "REDIS_PASSWORD": "",