diff --git a/core/api/src/app/authentication/email.ts b/core/api/src/app/authentication/email.ts index 6c029829f2..31e6f148a3 100644 --- a/core/api/src/app/authentication/email.ts +++ b/core/api/src/app/authentication/email.ts @@ -2,6 +2,7 @@ import { AccountAlreadyHasEmailError } from "@/domain/authentication/errors" import { AuthWithEmailPasswordlessService } from "@/services/kratos" import { baseLogger } from "@/services/logger" import { UsersRepository } from "@/services/mongoose" +import { NotificationsService } from "@/services/notifications" export const addEmailToIdentity = async ({ email, @@ -47,6 +48,11 @@ export const verifyEmail = async ({ }) if (res instanceof Error) return res + await NotificationsService().updateEmailAddress({ + userId: res.kratosUserId, + email: res.email, + }) + const user = await UsersRepository().findById(res.kratosUserId) if (user instanceof Error) return user @@ -74,5 +80,7 @@ export const removeEmail = async ({ }) if (updatedUser instanceof Error) return updatedUser + await NotificationsService().removeEmailAddress({ userId }) + return user } diff --git a/core/api/src/domain/notifications/index.types.d.ts b/core/api/src/domain/notifications/index.types.d.ts index d6d98d6620..677f84a46e 100644 --- a/core/api/src/domain/notifications/index.types.d.ts +++ b/core/api/src/domain/notifications/index.types.d.ts @@ -107,4 +107,11 @@ interface INotificationsService { userId: UserId deviceToken: DeviceToken }): Promise + + updateEmailAddress(args: { + userId: UserId + email: EmailAddress + }): Promise + + removeEmailAddress(args: { userId: UserId }): Promise } diff --git a/core/api/src/services/notifications/grpc-client.ts b/core/api/src/services/notifications/grpc-client.ts index dba5887b38..accdc045ae 100644 --- a/core/api/src/services/notifications/grpc-client.ts +++ b/core/api/src/services/notifications/grpc-client.ts @@ -23,6 +23,10 @@ import { AddPushDeviceTokenResponse, RemovePushDeviceTokenRequest, RemovePushDeviceTokenResponse, + UpdateEmailAddressRequest, + UpdateEmailAddressResponse, + RemoveEmailAddressRequest, + RemoveEmailAddressResponse, } from "./proto/notifications_pb" import { NOTIFICATIONS_HOST, NOTIFICATIONS_PORT } from "@/config" @@ -89,3 +93,15 @@ export const removePushDeviceToken = promisify< Metadata, RemovePushDeviceTokenResponse >(notificationsClient.removePushDeviceToken.bind(notificationsClient)) + +export const updateEmailAddress = promisify< + UpdateEmailAddressRequest, + Metadata, + UpdateEmailAddressResponse +>(notificationsClient.updateEmailAddress.bind(notificationsClient)) + +export const removeEmailAddress = promisify< + RemoveEmailAddressRequest, + Metadata, + RemoveEmailAddressResponse +>(notificationsClient.removeEmailAddress.bind(notificationsClient)) diff --git a/core/api/src/services/notifications/index.ts b/core/api/src/services/notifications/index.ts index 06be29e0bc..f4a40babdd 100644 --- a/core/api/src/services/notifications/index.ts +++ b/core/api/src/services/notifications/index.ts @@ -13,6 +13,8 @@ import { EnableNotificationChannelRequest, GetNotificationSettingsRequest, RemovePushDeviceTokenRequest, + UpdateEmailAddressRequest, + RemoveEmailAddressRequest, UpdateUserLocaleRequest, } from "./proto/notifications_pb" @@ -478,6 +480,49 @@ export const NotificationsService = (): INotificationsService => { } } + const updateEmailAddress = async ({ + userId, + email, + }: { + userId: UserId + email: EmailAddress + }): Promise => { + try { + const request = new UpdateEmailAddressRequest() + request.setUserId(userId) + request.setEmailAddress(email) + + await notificationsGrpc.updateEmailAddress( + request, + notificationsGrpc.notificationsMetadata, + ) + + return true + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + + const removeEmailAddress = async ({ + userId, + }: { + userId: UserId + }): Promise => { + try { + const request = new RemoveEmailAddressRequest() + request.setUserId(userId) + + await notificationsGrpc.removeEmailAddress( + request, + notificationsGrpc.notificationsMetadata, + ) + + return true + } catch (err) { + return new UnknownNotificationsServiceError(err) + } + } + const updateUserLanguage = async ({ userId, language, @@ -653,6 +698,8 @@ export const NotificationsService = (): INotificationsService => { enableNotificationCategory, disableNotificationCategory, addPushDeviceToken, + updateEmailAddress, + removeEmailAddress, removePushDeviceToken, }, }), diff --git a/core/api/src/services/notifications/proto/notifications.proto b/core/api/src/services/notifications/proto/notifications.proto index 5820eea2b1..5e9fe5184c 100644 --- a/core/api/src/services/notifications/proto/notifications.proto +++ b/core/api/src/services/notifications/proto/notifications.proto @@ -14,6 +14,9 @@ service NotificationsService { rpc UpdateUserLocale (UpdateUserLocaleRequest) returns (UpdateUserLocaleResponse) {} rpc AddPushDeviceToken (AddPushDeviceTokenRequest) returns (AddPushDeviceTokenResponse) {} rpc RemovePushDeviceToken (RemovePushDeviceTokenRequest) returns (RemovePushDeviceTokenResponse) {} + rpc UpdateEmailAddress (UpdateEmailAddressRequest) returns (UpdateEmailAddressResponse) {} + rpc RemoveEmailAddress (RemoveEmailAddressRequest) returns (RemoveEmailAddressResponse) {} + rpc HandleNotificationEvent (HandleNotificationEventRequest) returns (HandleNotificationEventResponse) {} } enum NotificationChannel { @@ -121,3 +124,74 @@ message RemovePushDeviceTokenRequest { message RemovePushDeviceTokenResponse { NotificationSettings notification_settings = 1; } + +message UpdateEmailAddressRequest { + string user_id = 1; + string email_address = 2; +} + +message UpdateEmailAddressResponse { } + +message RemoveEmailAddressRequest { + string user_id = 1; +} + +message RemoveEmailAddressResponse { } + +message HandleNotificationEventRequest { + NotificationEvent event = 1; +} + +message HandleNotificationEventResponse { } + +message NotificationEvent { + oneof data { + CircleGrew circle_grew = 1; + CircleThresholdReached circle_threshold_reached = 2; + IdentityVerificationApproved identity_verification_approved = 3; + IdentityVerificationDeclined identity_verification_declined = 4; + IdentityVerificationReviewPending identity_verification_review_pending = 5; + } +} + +enum CircleType { + INNER = 0; + OUTER = 1; +} + +message CircleGrew { + string user_id = 1; + CircleType circle_type = 2; + uint32 this_month_circle_size = 3; + uint32 all_time_circle_size = 4; +} + +enum CircleTimeFrame { + MONTH = 0; + ALL_TIME = 1; +} + +message CircleThresholdReached { + string user_id = 1; + CircleType circle_type = 2; + CircleTimeFrame time_frame = 3; + uint32 threshold = 4; +} + +message IdentityVerificationApproved { + string user_id = 1; +} + +enum DeclinedReason { + DOCUMENTS_NOT_CLEAR = 0; + VERIFICATION_PHOTO_NOT_CLEAR = 1; +} + +message IdentityVerificationDeclined { + string user_id = 1; + DeclinedReason declined_reason = 2; +} + +message IdentityVerificationReviewPending { + string user_id = 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 index 11fd9c69ae..1f4d233da6 100644 --- a/core/api/src/services/notifications/proto/notifications_grpc_pb.d.ts +++ b/core/api/src/services/notifications/proto/notifications_grpc_pb.d.ts @@ -18,6 +18,9 @@ interface INotificationsServiceService extends grpc.ServiceDefinition { @@ -101,6 +104,33 @@ interface INotificationsServiceService_IRemovePushDeviceToken extends grpc.Metho responseSerialize: grpc.serialize; responseDeserialize: grpc.deserialize; } +interface INotificationsServiceService_IUpdateEmailAddress extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/UpdateEmailAddress"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IRemoveEmailAddress extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/RemoveEmailAddress"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface INotificationsServiceService_IHandleNotificationEvent extends grpc.MethodDefinition { + path: "/services.notifications.v1.NotificationsService/HandleNotificationEvent"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} export const NotificationsServiceService: INotificationsServiceService; @@ -114,6 +144,9 @@ export interface INotificationsServiceServer extends grpc.UntypedServiceImplemen updateUserLocale: grpc.handleUnaryCall; addPushDeviceToken: grpc.handleUnaryCall; removePushDeviceToken: grpc.handleUnaryCall; + updateEmailAddress: grpc.handleUnaryCall; + removeEmailAddress: grpc.handleUnaryCall; + handleNotificationEvent: grpc.handleUnaryCall; } export interface INotificationsServiceClient { @@ -144,6 +177,15 @@ export interface INotificationsServiceClient { removePushDeviceToken(request: notifications_pb.RemovePushDeviceTokenRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemovePushDeviceTokenResponse) => void): grpc.ClientUnaryCall; removePushDeviceToken(request: notifications_pb.RemovePushDeviceTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemovePushDeviceTokenResponse) => void): grpc.ClientUnaryCall; removePushDeviceToken(request: notifications_pb.RemovePushDeviceTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemovePushDeviceTokenResponse) => void): grpc.ClientUnaryCall; + updateEmailAddress(request: notifications_pb.UpdateEmailAddressRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UpdateEmailAddressResponse) => void): grpc.ClientUnaryCall; + updateEmailAddress(request: notifications_pb.UpdateEmailAddressRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UpdateEmailAddressResponse) => void): grpc.ClientUnaryCall; + updateEmailAddress(request: notifications_pb.UpdateEmailAddressRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UpdateEmailAddressResponse) => void): grpc.ClientUnaryCall; + removeEmailAddress(request: notifications_pb.RemoveEmailAddressRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemoveEmailAddressResponse) => void): grpc.ClientUnaryCall; + removeEmailAddress(request: notifications_pb.RemoveEmailAddressRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemoveEmailAddressResponse) => void): grpc.ClientUnaryCall; + removeEmailAddress(request: notifications_pb.RemoveEmailAddressRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemoveEmailAddressResponse) => void): grpc.ClientUnaryCall; + handleNotificationEvent(request: notifications_pb.HandleNotificationEventRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.HandleNotificationEventResponse) => void): grpc.ClientUnaryCall; + handleNotificationEvent(request: notifications_pb.HandleNotificationEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.HandleNotificationEventResponse) => void): grpc.ClientUnaryCall; + handleNotificationEvent(request: notifications_pb.HandleNotificationEventRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.HandleNotificationEventResponse) => void): grpc.ClientUnaryCall; } export class NotificationsServiceClient extends grpc.Client implements INotificationsServiceClient { @@ -175,4 +217,13 @@ export class NotificationsServiceClient extends grpc.Client implements INotifica public removePushDeviceToken(request: notifications_pb.RemovePushDeviceTokenRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemovePushDeviceTokenResponse) => void): grpc.ClientUnaryCall; public removePushDeviceToken(request: notifications_pb.RemovePushDeviceTokenRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemovePushDeviceTokenResponse) => void): grpc.ClientUnaryCall; public removePushDeviceToken(request: notifications_pb.RemovePushDeviceTokenRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemovePushDeviceTokenResponse) => void): grpc.ClientUnaryCall; + public updateEmailAddress(request: notifications_pb.UpdateEmailAddressRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.UpdateEmailAddressResponse) => void): grpc.ClientUnaryCall; + public updateEmailAddress(request: notifications_pb.UpdateEmailAddressRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.UpdateEmailAddressResponse) => void): grpc.ClientUnaryCall; + public updateEmailAddress(request: notifications_pb.UpdateEmailAddressRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.UpdateEmailAddressResponse) => void): grpc.ClientUnaryCall; + public removeEmailAddress(request: notifications_pb.RemoveEmailAddressRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemoveEmailAddressResponse) => void): grpc.ClientUnaryCall; + public removeEmailAddress(request: notifications_pb.RemoveEmailAddressRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemoveEmailAddressResponse) => void): grpc.ClientUnaryCall; + public removeEmailAddress(request: notifications_pb.RemoveEmailAddressRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.RemoveEmailAddressResponse) => void): grpc.ClientUnaryCall; + public handleNotificationEvent(request: notifications_pb.HandleNotificationEventRequest, callback: (error: grpc.ServiceError | null, response: notifications_pb.HandleNotificationEventResponse) => void): grpc.ClientUnaryCall; + public handleNotificationEvent(request: notifications_pb.HandleNotificationEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: notifications_pb.HandleNotificationEventResponse) => void): grpc.ClientUnaryCall; + public handleNotificationEvent(request: notifications_pb.HandleNotificationEventRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: notifications_pb.HandleNotificationEventResponse) => 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 index c73961d78b..c6c5c4d9c9 100644 --- a/core/api/src/services/notifications/proto/notifications_grpc_pb.js +++ b/core/api/src/services/notifications/proto/notifications_grpc_pb.js @@ -137,6 +137,50 @@ function deserialize_services_notifications_v1_GetNotificationSettingsResponse(b return notifications_pb.GetNotificationSettingsResponse.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_services_notifications_v1_HandleNotificationEventRequest(arg) { + if (!(arg instanceof notifications_pb.HandleNotificationEventRequest)) { + throw new Error('Expected argument of type services.notifications.v1.HandleNotificationEventRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_HandleNotificationEventRequest(buffer_arg) { + return notifications_pb.HandleNotificationEventRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_HandleNotificationEventResponse(arg) { + if (!(arg instanceof notifications_pb.HandleNotificationEventResponse)) { + throw new Error('Expected argument of type services.notifications.v1.HandleNotificationEventResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_HandleNotificationEventResponse(buffer_arg) { + return notifications_pb.HandleNotificationEventResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_RemoveEmailAddressRequest(arg) { + if (!(arg instanceof notifications_pb.RemoveEmailAddressRequest)) { + throw new Error('Expected argument of type services.notifications.v1.RemoveEmailAddressRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_RemoveEmailAddressRequest(buffer_arg) { + return notifications_pb.RemoveEmailAddressRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_RemoveEmailAddressResponse(arg) { + if (!(arg instanceof notifications_pb.RemoveEmailAddressResponse)) { + throw new Error('Expected argument of type services.notifications.v1.RemoveEmailAddressResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_RemoveEmailAddressResponse(buffer_arg) { + return notifications_pb.RemoveEmailAddressResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_services_notifications_v1_RemovePushDeviceTokenRequest(arg) { if (!(arg instanceof notifications_pb.RemovePushDeviceTokenRequest)) { throw new Error('Expected argument of type services.notifications.v1.RemovePushDeviceTokenRequest'); @@ -181,6 +225,28 @@ function deserialize_services_notifications_v1_ShouldSendNotificationResponse(bu return notifications_pb.ShouldSendNotificationResponse.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_services_notifications_v1_UpdateEmailAddressRequest(arg) { + if (!(arg instanceof notifications_pb.UpdateEmailAddressRequest)) { + throw new Error('Expected argument of type services.notifications.v1.UpdateEmailAddressRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UpdateEmailAddressRequest(buffer_arg) { + return notifications_pb.UpdateEmailAddressRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_services_notifications_v1_UpdateEmailAddressResponse(arg) { + if (!(arg instanceof notifications_pb.UpdateEmailAddressResponse)) { + throw new Error('Expected argument of type services.notifications.v1.UpdateEmailAddressResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_services_notifications_v1_UpdateEmailAddressResponse(buffer_arg) { + return notifications_pb.UpdateEmailAddressResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_services_notifications_v1_UpdateUserLocaleRequest(arg) { if (!(arg instanceof notifications_pb.UpdateUserLocaleRequest)) { throw new Error('Expected argument of type services.notifications.v1.UpdateUserLocaleRequest'); @@ -304,6 +370,39 @@ var NotificationsServiceService = exports.NotificationsServiceService = { responseSerialize: serialize_services_notifications_v1_RemovePushDeviceTokenResponse, responseDeserialize: deserialize_services_notifications_v1_RemovePushDeviceTokenResponse, }, + updateEmailAddress: { + path: '/services.notifications.v1.NotificationsService/UpdateEmailAddress', + requestStream: false, + responseStream: false, + requestType: notifications_pb.UpdateEmailAddressRequest, + responseType: notifications_pb.UpdateEmailAddressResponse, + requestSerialize: serialize_services_notifications_v1_UpdateEmailAddressRequest, + requestDeserialize: deserialize_services_notifications_v1_UpdateEmailAddressRequest, + responseSerialize: serialize_services_notifications_v1_UpdateEmailAddressResponse, + responseDeserialize: deserialize_services_notifications_v1_UpdateEmailAddressResponse, + }, + removeEmailAddress: { + path: '/services.notifications.v1.NotificationsService/RemoveEmailAddress', + requestStream: false, + responseStream: false, + requestType: notifications_pb.RemoveEmailAddressRequest, + responseType: notifications_pb.RemoveEmailAddressResponse, + requestSerialize: serialize_services_notifications_v1_RemoveEmailAddressRequest, + requestDeserialize: deserialize_services_notifications_v1_RemoveEmailAddressRequest, + responseSerialize: serialize_services_notifications_v1_RemoveEmailAddressResponse, + responseDeserialize: deserialize_services_notifications_v1_RemoveEmailAddressResponse, + }, + handleNotificationEvent: { + path: '/services.notifications.v1.NotificationsService/HandleNotificationEvent', + requestStream: false, + responseStream: false, + requestType: notifications_pb.HandleNotificationEventRequest, + responseType: notifications_pb.HandleNotificationEventResponse, + requestSerialize: serialize_services_notifications_v1_HandleNotificationEventRequest, + requestDeserialize: deserialize_services_notifications_v1_HandleNotificationEventRequest, + responseSerialize: serialize_services_notifications_v1_HandleNotificationEventResponse, + responseDeserialize: deserialize_services_notifications_v1_HandleNotificationEventResponse, + }, }; 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 index 8325e776b7..4b974a3573 100644 --- a/core/api/src/services/notifications/proto/notifications_pb.d.ts +++ b/core/api/src/services/notifications/proto/notifications_pb.d.ts @@ -486,6 +486,303 @@ export namespace RemovePushDeviceTokenResponse { } } +export class UpdateEmailAddressRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): UpdateEmailAddressRequest; + getEmailAddress(): string; + setEmailAddress(value: string): UpdateEmailAddressRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UpdateEmailAddressRequest.AsObject; + static toObject(includeInstance: boolean, msg: UpdateEmailAddressRequest): UpdateEmailAddressRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UpdateEmailAddressRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UpdateEmailAddressRequest; + static deserializeBinaryFromReader(message: UpdateEmailAddressRequest, reader: jspb.BinaryReader): UpdateEmailAddressRequest; +} + +export namespace UpdateEmailAddressRequest { + export type AsObject = { + userId: string, + emailAddress: string, + } +} + +export class UpdateEmailAddressResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UpdateEmailAddressResponse.AsObject; + static toObject(includeInstance: boolean, msg: UpdateEmailAddressResponse): UpdateEmailAddressResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UpdateEmailAddressResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UpdateEmailAddressResponse; + static deserializeBinaryFromReader(message: UpdateEmailAddressResponse, reader: jspb.BinaryReader): UpdateEmailAddressResponse; +} + +export namespace UpdateEmailAddressResponse { + export type AsObject = { + } +} + +export class RemoveEmailAddressRequest extends jspb.Message { + getUserId(): string; + setUserId(value: string): RemoveEmailAddressRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RemoveEmailAddressRequest.AsObject; + static toObject(includeInstance: boolean, msg: RemoveEmailAddressRequest): RemoveEmailAddressRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RemoveEmailAddressRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RemoveEmailAddressRequest; + static deserializeBinaryFromReader(message: RemoveEmailAddressRequest, reader: jspb.BinaryReader): RemoveEmailAddressRequest; +} + +export namespace RemoveEmailAddressRequest { + export type AsObject = { + userId: string, + } +} + +export class RemoveEmailAddressResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RemoveEmailAddressResponse.AsObject; + static toObject(includeInstance: boolean, msg: RemoveEmailAddressResponse): RemoveEmailAddressResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RemoveEmailAddressResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RemoveEmailAddressResponse; + static deserializeBinaryFromReader(message: RemoveEmailAddressResponse, reader: jspb.BinaryReader): RemoveEmailAddressResponse; +} + +export namespace RemoveEmailAddressResponse { + export type AsObject = { + } +} + +export class HandleNotificationEventRequest extends jspb.Message { + + hasEvent(): boolean; + clearEvent(): void; + getEvent(): NotificationEvent | undefined; + setEvent(value?: NotificationEvent): HandleNotificationEventRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HandleNotificationEventRequest.AsObject; + static toObject(includeInstance: boolean, msg: HandleNotificationEventRequest): HandleNotificationEventRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: HandleNotificationEventRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HandleNotificationEventRequest; + static deserializeBinaryFromReader(message: HandleNotificationEventRequest, reader: jspb.BinaryReader): HandleNotificationEventRequest; +} + +export namespace HandleNotificationEventRequest { + export type AsObject = { + event?: NotificationEvent.AsObject, + } +} + +export class HandleNotificationEventResponse extends jspb.Message { + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HandleNotificationEventResponse.AsObject; + static toObject(includeInstance: boolean, msg: HandleNotificationEventResponse): HandleNotificationEventResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: HandleNotificationEventResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HandleNotificationEventResponse; + static deserializeBinaryFromReader(message: HandleNotificationEventResponse, reader: jspb.BinaryReader): HandleNotificationEventResponse; +} + +export namespace HandleNotificationEventResponse { + export type AsObject = { + } +} + +export class NotificationEvent extends jspb.Message { + + hasCircleGrew(): boolean; + clearCircleGrew(): void; + getCircleGrew(): CircleGrew | undefined; + setCircleGrew(value?: CircleGrew): NotificationEvent; + + hasCircleThresholdReached(): boolean; + clearCircleThresholdReached(): void; + getCircleThresholdReached(): CircleThresholdReached | undefined; + setCircleThresholdReached(value?: CircleThresholdReached): NotificationEvent; + + hasIdentityVerificationApproved(): boolean; + clearIdentityVerificationApproved(): void; + getIdentityVerificationApproved(): IdentityVerificationApproved | undefined; + setIdentityVerificationApproved(value?: IdentityVerificationApproved): NotificationEvent; + + hasIdentityVerificationDeclined(): boolean; + clearIdentityVerificationDeclined(): void; + getIdentityVerificationDeclined(): IdentityVerificationDeclined | undefined; + setIdentityVerificationDeclined(value?: IdentityVerificationDeclined): NotificationEvent; + + hasIdentityVerificationReviewPending(): boolean; + clearIdentityVerificationReviewPending(): void; + getIdentityVerificationReviewPending(): IdentityVerificationReviewPending | undefined; + setIdentityVerificationReviewPending(value?: IdentityVerificationReviewPending): NotificationEvent; + + getDataCase(): NotificationEvent.DataCase; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): NotificationEvent.AsObject; + static toObject(includeInstance: boolean, msg: NotificationEvent): NotificationEvent.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: NotificationEvent, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): NotificationEvent; + static deserializeBinaryFromReader(message: NotificationEvent, reader: jspb.BinaryReader): NotificationEvent; +} + +export namespace NotificationEvent { + export type AsObject = { + circleGrew?: CircleGrew.AsObject, + circleThresholdReached?: CircleThresholdReached.AsObject, + identityVerificationApproved?: IdentityVerificationApproved.AsObject, + identityVerificationDeclined?: IdentityVerificationDeclined.AsObject, + identityVerificationReviewPending?: IdentityVerificationReviewPending.AsObject, + } + + export enum DataCase { + DATA_NOT_SET = 0, + CIRCLE_GREW = 1, + CIRCLE_THRESHOLD_REACHED = 2, + IDENTITY_VERIFICATION_APPROVED = 3, + IDENTITY_VERIFICATION_DECLINED = 4, + IDENTITY_VERIFICATION_REVIEW_PENDING = 5, + } + +} + +export class CircleGrew extends jspb.Message { + getUserId(): string; + setUserId(value: string): CircleGrew; + getCircleType(): CircleType; + setCircleType(value: CircleType): CircleGrew; + getThisMonthCircleSize(): number; + setThisMonthCircleSize(value: number): CircleGrew; + getAllTimeCircleSize(): number; + setAllTimeCircleSize(value: number): CircleGrew; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): CircleGrew.AsObject; + static toObject(includeInstance: boolean, msg: CircleGrew): CircleGrew.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: CircleGrew, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): CircleGrew; + static deserializeBinaryFromReader(message: CircleGrew, reader: jspb.BinaryReader): CircleGrew; +} + +export namespace CircleGrew { + export type AsObject = { + userId: string, + circleType: CircleType, + thisMonthCircleSize: number, + allTimeCircleSize: number, + } +} + +export class CircleThresholdReached extends jspb.Message { + getUserId(): string; + setUserId(value: string): CircleThresholdReached; + getCircleType(): CircleType; + setCircleType(value: CircleType): CircleThresholdReached; + getTimeFrame(): CircleTimeFrame; + setTimeFrame(value: CircleTimeFrame): CircleThresholdReached; + getThreshold(): number; + setThreshold(value: number): CircleThresholdReached; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): CircleThresholdReached.AsObject; + static toObject(includeInstance: boolean, msg: CircleThresholdReached): CircleThresholdReached.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: CircleThresholdReached, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): CircleThresholdReached; + static deserializeBinaryFromReader(message: CircleThresholdReached, reader: jspb.BinaryReader): CircleThresholdReached; +} + +export namespace CircleThresholdReached { + export type AsObject = { + userId: string, + circleType: CircleType, + timeFrame: CircleTimeFrame, + threshold: number, + } +} + +export class IdentityVerificationApproved extends jspb.Message { + getUserId(): string; + setUserId(value: string): IdentityVerificationApproved; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): IdentityVerificationApproved.AsObject; + static toObject(includeInstance: boolean, msg: IdentityVerificationApproved): IdentityVerificationApproved.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: IdentityVerificationApproved, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): IdentityVerificationApproved; + static deserializeBinaryFromReader(message: IdentityVerificationApproved, reader: jspb.BinaryReader): IdentityVerificationApproved; +} + +export namespace IdentityVerificationApproved { + export type AsObject = { + userId: string, + } +} + +export class IdentityVerificationDeclined extends jspb.Message { + getUserId(): string; + setUserId(value: string): IdentityVerificationDeclined; + getDeclinedReason(): DeclinedReason; + setDeclinedReason(value: DeclinedReason): IdentityVerificationDeclined; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): IdentityVerificationDeclined.AsObject; + static toObject(includeInstance: boolean, msg: IdentityVerificationDeclined): IdentityVerificationDeclined.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: IdentityVerificationDeclined, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): IdentityVerificationDeclined; + static deserializeBinaryFromReader(message: IdentityVerificationDeclined, reader: jspb.BinaryReader): IdentityVerificationDeclined; +} + +export namespace IdentityVerificationDeclined { + export type AsObject = { + userId: string, + declinedReason: DeclinedReason, + } +} + +export class IdentityVerificationReviewPending extends jspb.Message { + getUserId(): string; + setUserId(value: string): IdentityVerificationReviewPending; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): IdentityVerificationReviewPending.AsObject; + static toObject(includeInstance: boolean, msg: IdentityVerificationReviewPending): IdentityVerificationReviewPending.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: IdentityVerificationReviewPending, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): IdentityVerificationReviewPending; + static deserializeBinaryFromReader(message: IdentityVerificationReviewPending, reader: jspb.BinaryReader): IdentityVerificationReviewPending; +} + +export namespace IdentityVerificationReviewPending { + export type AsObject = { + userId: string, + } +} + export enum NotificationChannel { PUSH = 0, } @@ -496,3 +793,18 @@ export enum NotificationCategory { BALANCE = 2, ADMIN_NOTIFICATION = 3, } + +export enum CircleType { + INNER = 0, + OUTER = 1, +} + +export enum CircleTimeFrame { + MONTH = 0, + ALL_TIME = 1, +} + +export enum DeclinedReason { + DOCUMENTS_NOT_CLEAR = 0, + VERIFICATION_PHOTO_NOT_CLEAR = 1, +} diff --git a/core/api/src/services/notifications/proto/notifications_pb.js b/core/api/src/services/notifications/proto/notifications_pb.js index a7e5c2ab3a..4fc5d4f552 100644 --- a/core/api/src/services/notifications/proto/notifications_pb.js +++ b/core/api/src/services/notifications/proto/notifications_pb.js @@ -26,6 +26,11 @@ goog.object.extend(proto, google_protobuf_struct_pb); goog.exportSymbol('proto.services.notifications.v1.AddPushDeviceTokenRequest', null, global); goog.exportSymbol('proto.services.notifications.v1.AddPushDeviceTokenResponse', null, global); goog.exportSymbol('proto.services.notifications.v1.ChannelNotificationSettings', null, global); +goog.exportSymbol('proto.services.notifications.v1.CircleGrew', null, global); +goog.exportSymbol('proto.services.notifications.v1.CircleThresholdReached', null, global); +goog.exportSymbol('proto.services.notifications.v1.CircleTimeFrame', null, global); +goog.exportSymbol('proto.services.notifications.v1.CircleType', null, global); +goog.exportSymbol('proto.services.notifications.v1.DeclinedReason', null, global); goog.exportSymbol('proto.services.notifications.v1.DisableNotificationCategoryRequest', null, global); goog.exportSymbol('proto.services.notifications.v1.DisableNotificationCategoryResponse', null, global); goog.exportSymbol('proto.services.notifications.v1.DisableNotificationChannelRequest', null, global); @@ -36,13 +41,24 @@ goog.exportSymbol('proto.services.notifications.v1.EnableNotificationChannelRequ goog.exportSymbol('proto.services.notifications.v1.EnableNotificationChannelResponse', null, global); goog.exportSymbol('proto.services.notifications.v1.GetNotificationSettingsRequest', null, global); goog.exportSymbol('proto.services.notifications.v1.GetNotificationSettingsResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.HandleNotificationEventRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.HandleNotificationEventResponse', null, global); +goog.exportSymbol('proto.services.notifications.v1.IdentityVerificationApproved', null, global); +goog.exportSymbol('proto.services.notifications.v1.IdentityVerificationDeclined', null, global); +goog.exportSymbol('proto.services.notifications.v1.IdentityVerificationReviewPending', 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.NotificationEvent', null, global); +goog.exportSymbol('proto.services.notifications.v1.NotificationEvent.DataCase', null, global); goog.exportSymbol('proto.services.notifications.v1.NotificationSettings', null, global); +goog.exportSymbol('proto.services.notifications.v1.RemoveEmailAddressRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.RemoveEmailAddressResponse', null, global); goog.exportSymbol('proto.services.notifications.v1.RemovePushDeviceTokenRequest', null, global); goog.exportSymbol('proto.services.notifications.v1.RemovePushDeviceTokenResponse', 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.UpdateEmailAddressRequest', null, global); +goog.exportSymbol('proto.services.notifications.v1.UpdateEmailAddressResponse', null, global); goog.exportSymbol('proto.services.notifications.v1.UpdateUserLocaleRequest', null, global); goog.exportSymbol('proto.services.notifications.v1.UpdateUserLocaleResponse', null, global); /** @@ -465,6 +481,258 @@ if (goog.DEBUG && !COMPILED) { */ proto.services.notifications.v1.RemovePushDeviceTokenResponse.displayName = 'proto.services.notifications.v1.RemovePushDeviceTokenResponse'; } +/** + * 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.UpdateEmailAddressRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UpdateEmailAddressRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UpdateEmailAddressRequest.displayName = 'proto.services.notifications.v1.UpdateEmailAddressRequest'; +} +/** + * 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.UpdateEmailAddressResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.UpdateEmailAddressResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.UpdateEmailAddressResponse.displayName = 'proto.services.notifications.v1.UpdateEmailAddressResponse'; +} +/** + * 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.RemoveEmailAddressRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.RemoveEmailAddressRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.RemoveEmailAddressRequest.displayName = 'proto.services.notifications.v1.RemoveEmailAddressRequest'; +} +/** + * 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.RemoveEmailAddressResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.RemoveEmailAddressResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.RemoveEmailAddressResponse.displayName = 'proto.services.notifications.v1.RemoveEmailAddressResponse'; +} +/** + * 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.HandleNotificationEventRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.HandleNotificationEventRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.HandleNotificationEventRequest.displayName = 'proto.services.notifications.v1.HandleNotificationEventRequest'; +} +/** + * 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.HandleNotificationEventResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.HandleNotificationEventResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.HandleNotificationEventResponse.displayName = 'proto.services.notifications.v1.HandleNotificationEventResponse'; +} +/** + * 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.NotificationEvent = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.services.notifications.v1.NotificationEvent.oneofGroups_); +}; +goog.inherits(proto.services.notifications.v1.NotificationEvent, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.NotificationEvent.displayName = 'proto.services.notifications.v1.NotificationEvent'; +} +/** + * 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.CircleGrew = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.CircleGrew, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.CircleGrew.displayName = 'proto.services.notifications.v1.CircleGrew'; +} +/** + * 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.CircleThresholdReached = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.CircleThresholdReached, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.CircleThresholdReached.displayName = 'proto.services.notifications.v1.CircleThresholdReached'; +} +/** + * 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.IdentityVerificationApproved = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.IdentityVerificationApproved, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.IdentityVerificationApproved.displayName = 'proto.services.notifications.v1.IdentityVerificationApproved'; +} +/** + * 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.IdentityVerificationDeclined = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.IdentityVerificationDeclined, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.IdentityVerificationDeclined.displayName = 'proto.services.notifications.v1.IdentityVerificationDeclined'; +} +/** + * 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.IdentityVerificationReviewPending = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.services.notifications.v1.IdentityVerificationReviewPending, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.services.notifications.v1.IdentityVerificationReviewPending.displayName = 'proto.services.notifications.v1.IdentityVerificationReviewPending'; +} @@ -3776,21 +4044,2033 @@ proto.services.notifications.v1.RemovePushDeviceTokenResponse.prototype.hasNotif }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * @enum {number} + * 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.NotificationChannel = { - PUSH: 0 +proto.services.notifications.v1.UpdateEmailAddressRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UpdateEmailAddressRequest.toObject(opt_includeInstance, this); }; + /** - * @enum {number} + * 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.UpdateEmailAddressRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.services.notifications.v1.NotificationCategory = { - CIRCLES: 0, - PAYMENTS: 1, - BALANCE: 2, - ADMIN_NOTIFICATION: 3 +proto.services.notifications.v1.UpdateEmailAddressRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + emailAddress: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + 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.UpdateEmailAddressRequest} + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UpdateEmailAddressRequest; + return proto.services.notifications.v1.UpdateEmailAddressRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UpdateEmailAddressRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UpdateEmailAddressRequest} + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.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 {string} */ (reader.readString()); + msg.setEmailAddress(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UpdateEmailAddressRequest.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.UpdateEmailAddressRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getEmailAddress(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UpdateEmailAddressRequest} returns this + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string email_address = 2; + * @return {string} + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.prototype.getEmailAddress = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.UpdateEmailAddressRequest} returns this + */ +proto.services.notifications.v1.UpdateEmailAddressRequest.prototype.setEmailAddress = function(value) { + return jspb.Message.setProto3StringField(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.UpdateEmailAddressResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.UpdateEmailAddressResponse.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.UpdateEmailAddressResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UpdateEmailAddressResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.UpdateEmailAddressResponse} + */ +proto.services.notifications.v1.UpdateEmailAddressResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.UpdateEmailAddressResponse; + return proto.services.notifications.v1.UpdateEmailAddressResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.UpdateEmailAddressResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.UpdateEmailAddressResponse} + */ +proto.services.notifications.v1.UpdateEmailAddressResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.UpdateEmailAddressResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.UpdateEmailAddressResponse.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.UpdateEmailAddressResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.UpdateEmailAddressResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.RemoveEmailAddressRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.RemoveEmailAddressRequest.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.RemoveEmailAddressRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.RemoveEmailAddressRequest.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.RemoveEmailAddressRequest} + */ +proto.services.notifications.v1.RemoveEmailAddressRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.RemoveEmailAddressRequest; + return proto.services.notifications.v1.RemoveEmailAddressRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.RemoveEmailAddressRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.RemoveEmailAddressRequest} + */ +proto.services.notifications.v1.RemoveEmailAddressRequest.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.RemoveEmailAddressRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.RemoveEmailAddressRequest.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.RemoveEmailAddressRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.RemoveEmailAddressRequest.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.RemoveEmailAddressRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.RemoveEmailAddressRequest} returns this + */ +proto.services.notifications.v1.RemoveEmailAddressRequest.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.RemoveEmailAddressResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.RemoveEmailAddressResponse.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.RemoveEmailAddressResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.RemoveEmailAddressResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.RemoveEmailAddressResponse} + */ +proto.services.notifications.v1.RemoveEmailAddressResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.RemoveEmailAddressResponse; + return proto.services.notifications.v1.RemoveEmailAddressResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.RemoveEmailAddressResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.RemoveEmailAddressResponse} + */ +proto.services.notifications.v1.RemoveEmailAddressResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.RemoveEmailAddressResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.RemoveEmailAddressResponse.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.RemoveEmailAddressResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.RemoveEmailAddressResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.HandleNotificationEventRequest.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.HandleNotificationEventRequest.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.HandleNotificationEventRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.HandleNotificationEventRequest.toObject = function(includeInstance, msg) { + var f, obj = { + event: (f = msg.getEvent()) && proto.services.notifications.v1.NotificationEvent.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.HandleNotificationEventRequest} + */ +proto.services.notifications.v1.HandleNotificationEventRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.HandleNotificationEventRequest; + return proto.services.notifications.v1.HandleNotificationEventRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.HandleNotificationEventRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.HandleNotificationEventRequest} + */ +proto.services.notifications.v1.HandleNotificationEventRequest.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.NotificationEvent; + reader.readMessage(value,proto.services.notifications.v1.NotificationEvent.deserializeBinaryFromReader); + msg.setEvent(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.HandleNotificationEventRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.HandleNotificationEventRequest.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.HandleNotificationEventRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.HandleNotificationEventRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getEvent(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.NotificationEvent.serializeBinaryToWriter + ); + } +}; + + +/** + * optional NotificationEvent event = 1; + * @return {?proto.services.notifications.v1.NotificationEvent} + */ +proto.services.notifications.v1.HandleNotificationEventRequest.prototype.getEvent = function() { + return /** @type{?proto.services.notifications.v1.NotificationEvent} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.NotificationEvent, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.NotificationEvent|undefined} value + * @return {!proto.services.notifications.v1.HandleNotificationEventRequest} returns this +*/ +proto.services.notifications.v1.HandleNotificationEventRequest.prototype.setEvent = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.HandleNotificationEventRequest} returns this + */ +proto.services.notifications.v1.HandleNotificationEventRequest.prototype.clearEvent = function() { + return this.setEvent(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.HandleNotificationEventRequest.prototype.hasEvent = 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.HandleNotificationEventResponse.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.HandleNotificationEventResponse.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.HandleNotificationEventResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.HandleNotificationEventResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.HandleNotificationEventResponse} + */ +proto.services.notifications.v1.HandleNotificationEventResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.HandleNotificationEventResponse; + return proto.services.notifications.v1.HandleNotificationEventResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.HandleNotificationEventResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.HandleNotificationEventResponse} + */ +proto.services.notifications.v1.HandleNotificationEventResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.HandleNotificationEventResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.HandleNotificationEventResponse.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.HandleNotificationEventResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.HandleNotificationEventResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.services.notifications.v1.NotificationEvent.oneofGroups_ = [[1,2,3,4,5]]; + +/** + * @enum {number} + */ +proto.services.notifications.v1.NotificationEvent.DataCase = { + DATA_NOT_SET: 0, + CIRCLE_GREW: 1, + CIRCLE_THRESHOLD_REACHED: 2, + IDENTITY_VERIFICATION_APPROVED: 3, + IDENTITY_VERIFICATION_DECLINED: 4, + IDENTITY_VERIFICATION_REVIEW_PENDING: 5 +}; + +/** + * @return {proto.services.notifications.v1.NotificationEvent.DataCase} + */ +proto.services.notifications.v1.NotificationEvent.prototype.getDataCase = function() { + return /** @type {proto.services.notifications.v1.NotificationEvent.DataCase} */(jspb.Message.computeOneofCase(this, proto.services.notifications.v1.NotificationEvent.oneofGroups_[0])); +}; + + + +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.NotificationEvent.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.NotificationEvent.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.NotificationEvent} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.NotificationEvent.toObject = function(includeInstance, msg) { + var f, obj = { + circleGrew: (f = msg.getCircleGrew()) && proto.services.notifications.v1.CircleGrew.toObject(includeInstance, f), + circleThresholdReached: (f = msg.getCircleThresholdReached()) && proto.services.notifications.v1.CircleThresholdReached.toObject(includeInstance, f), + identityVerificationApproved: (f = msg.getIdentityVerificationApproved()) && proto.services.notifications.v1.IdentityVerificationApproved.toObject(includeInstance, f), + identityVerificationDeclined: (f = msg.getIdentityVerificationDeclined()) && proto.services.notifications.v1.IdentityVerificationDeclined.toObject(includeInstance, f), + identityVerificationReviewPending: (f = msg.getIdentityVerificationReviewPending()) && proto.services.notifications.v1.IdentityVerificationReviewPending.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.NotificationEvent} + */ +proto.services.notifications.v1.NotificationEvent.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.NotificationEvent; + return proto.services.notifications.v1.NotificationEvent.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.NotificationEvent} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.NotificationEvent} + */ +proto.services.notifications.v1.NotificationEvent.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.CircleGrew; + reader.readMessage(value,proto.services.notifications.v1.CircleGrew.deserializeBinaryFromReader); + msg.setCircleGrew(value); + break; + case 2: + var value = new proto.services.notifications.v1.CircleThresholdReached; + reader.readMessage(value,proto.services.notifications.v1.CircleThresholdReached.deserializeBinaryFromReader); + msg.setCircleThresholdReached(value); + break; + case 3: + var value = new proto.services.notifications.v1.IdentityVerificationApproved; + reader.readMessage(value,proto.services.notifications.v1.IdentityVerificationApproved.deserializeBinaryFromReader); + msg.setIdentityVerificationApproved(value); + break; + case 4: + var value = new proto.services.notifications.v1.IdentityVerificationDeclined; + reader.readMessage(value,proto.services.notifications.v1.IdentityVerificationDeclined.deserializeBinaryFromReader); + msg.setIdentityVerificationDeclined(value); + break; + case 5: + var value = new proto.services.notifications.v1.IdentityVerificationReviewPending; + reader.readMessage(value,proto.services.notifications.v1.IdentityVerificationReviewPending.deserializeBinaryFromReader); + msg.setIdentityVerificationReviewPending(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.NotificationEvent.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.NotificationEvent.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.NotificationEvent} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.NotificationEvent.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCircleGrew(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.services.notifications.v1.CircleGrew.serializeBinaryToWriter + ); + } + f = message.getCircleThresholdReached(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.services.notifications.v1.CircleThresholdReached.serializeBinaryToWriter + ); + } + f = message.getIdentityVerificationApproved(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.services.notifications.v1.IdentityVerificationApproved.serializeBinaryToWriter + ); + } + f = message.getIdentityVerificationDeclined(); + if (f != null) { + writer.writeMessage( + 4, + f, + proto.services.notifications.v1.IdentityVerificationDeclined.serializeBinaryToWriter + ); + } + f = message.getIdentityVerificationReviewPending(); + if (f != null) { + writer.writeMessage( + 5, + f, + proto.services.notifications.v1.IdentityVerificationReviewPending.serializeBinaryToWriter + ); + } +}; + + +/** + * optional CircleGrew circle_grew = 1; + * @return {?proto.services.notifications.v1.CircleGrew} + */ +proto.services.notifications.v1.NotificationEvent.prototype.getCircleGrew = function() { + return /** @type{?proto.services.notifications.v1.CircleGrew} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.CircleGrew, 1)); +}; + + +/** + * @param {?proto.services.notifications.v1.CircleGrew|undefined} value + * @return {!proto.services.notifications.v1.NotificationEvent} returns this +*/ +proto.services.notifications.v1.NotificationEvent.prototype.setCircleGrew = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.services.notifications.v1.NotificationEvent.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.NotificationEvent} returns this + */ +proto.services.notifications.v1.NotificationEvent.prototype.clearCircleGrew = function() { + return this.setCircleGrew(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.NotificationEvent.prototype.hasCircleGrew = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional CircleThresholdReached circle_threshold_reached = 2; + * @return {?proto.services.notifications.v1.CircleThresholdReached} + */ +proto.services.notifications.v1.NotificationEvent.prototype.getCircleThresholdReached = function() { + return /** @type{?proto.services.notifications.v1.CircleThresholdReached} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.CircleThresholdReached, 2)); +}; + + +/** + * @param {?proto.services.notifications.v1.CircleThresholdReached|undefined} value + * @return {!proto.services.notifications.v1.NotificationEvent} returns this +*/ +proto.services.notifications.v1.NotificationEvent.prototype.setCircleThresholdReached = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.services.notifications.v1.NotificationEvent.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.NotificationEvent} returns this + */ +proto.services.notifications.v1.NotificationEvent.prototype.clearCircleThresholdReached = function() { + return this.setCircleThresholdReached(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.NotificationEvent.prototype.hasCircleThresholdReached = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional IdentityVerificationApproved identity_verification_approved = 3; + * @return {?proto.services.notifications.v1.IdentityVerificationApproved} + */ +proto.services.notifications.v1.NotificationEvent.prototype.getIdentityVerificationApproved = function() { + return /** @type{?proto.services.notifications.v1.IdentityVerificationApproved} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.IdentityVerificationApproved, 3)); +}; + + +/** + * @param {?proto.services.notifications.v1.IdentityVerificationApproved|undefined} value + * @return {!proto.services.notifications.v1.NotificationEvent} returns this +*/ +proto.services.notifications.v1.NotificationEvent.prototype.setIdentityVerificationApproved = function(value) { + return jspb.Message.setOneofWrapperField(this, 3, proto.services.notifications.v1.NotificationEvent.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.NotificationEvent} returns this + */ +proto.services.notifications.v1.NotificationEvent.prototype.clearIdentityVerificationApproved = function() { + return this.setIdentityVerificationApproved(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.NotificationEvent.prototype.hasIdentityVerificationApproved = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional IdentityVerificationDeclined identity_verification_declined = 4; + * @return {?proto.services.notifications.v1.IdentityVerificationDeclined} + */ +proto.services.notifications.v1.NotificationEvent.prototype.getIdentityVerificationDeclined = function() { + return /** @type{?proto.services.notifications.v1.IdentityVerificationDeclined} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.IdentityVerificationDeclined, 4)); +}; + + +/** + * @param {?proto.services.notifications.v1.IdentityVerificationDeclined|undefined} value + * @return {!proto.services.notifications.v1.NotificationEvent} returns this +*/ +proto.services.notifications.v1.NotificationEvent.prototype.setIdentityVerificationDeclined = function(value) { + return jspb.Message.setOneofWrapperField(this, 4, proto.services.notifications.v1.NotificationEvent.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.NotificationEvent} returns this + */ +proto.services.notifications.v1.NotificationEvent.prototype.clearIdentityVerificationDeclined = function() { + return this.setIdentityVerificationDeclined(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.NotificationEvent.prototype.hasIdentityVerificationDeclined = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional IdentityVerificationReviewPending identity_verification_review_pending = 5; + * @return {?proto.services.notifications.v1.IdentityVerificationReviewPending} + */ +proto.services.notifications.v1.NotificationEvent.prototype.getIdentityVerificationReviewPending = function() { + return /** @type{?proto.services.notifications.v1.IdentityVerificationReviewPending} */ ( + jspb.Message.getWrapperField(this, proto.services.notifications.v1.IdentityVerificationReviewPending, 5)); +}; + + +/** + * @param {?proto.services.notifications.v1.IdentityVerificationReviewPending|undefined} value + * @return {!proto.services.notifications.v1.NotificationEvent} returns this +*/ +proto.services.notifications.v1.NotificationEvent.prototype.setIdentityVerificationReviewPending = function(value) { + return jspb.Message.setOneofWrapperField(this, 5, proto.services.notifications.v1.NotificationEvent.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.services.notifications.v1.NotificationEvent} returns this + */ +proto.services.notifications.v1.NotificationEvent.prototype.clearIdentityVerificationReviewPending = function() { + return this.setIdentityVerificationReviewPending(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.services.notifications.v1.NotificationEvent.prototype.hasIdentityVerificationReviewPending = function() { + return jspb.Message.getField(this, 5) != 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.CircleGrew.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.CircleGrew.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.CircleGrew} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.CircleGrew.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + circleType: jspb.Message.getFieldWithDefault(msg, 2, 0), + thisMonthCircleSize: jspb.Message.getFieldWithDefault(msg, 3, 0), + allTimeCircleSize: jspb.Message.getFieldWithDefault(msg, 4, 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.CircleGrew} + */ +proto.services.notifications.v1.CircleGrew.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.CircleGrew; + return proto.services.notifications.v1.CircleGrew.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.CircleGrew} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.CircleGrew} + */ +proto.services.notifications.v1.CircleGrew.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.CircleType} */ (reader.readEnum()); + msg.setCircleType(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint32()); + msg.setThisMonthCircleSize(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint32()); + msg.setAllTimeCircleSize(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.CircleGrew.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.CircleGrew.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.CircleGrew} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.CircleGrew.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getCircleType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getThisMonthCircleSize(); + if (f !== 0) { + writer.writeUint32( + 3, + f + ); + } + f = message.getAllTimeCircleSize(); + if (f !== 0) { + writer.writeUint32( + 4, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.CircleGrew.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.CircleGrew} returns this + */ +proto.services.notifications.v1.CircleGrew.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional CircleType circle_type = 2; + * @return {!proto.services.notifications.v1.CircleType} + */ +proto.services.notifications.v1.CircleGrew.prototype.getCircleType = function() { + return /** @type {!proto.services.notifications.v1.CircleType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.CircleType} value + * @return {!proto.services.notifications.v1.CircleGrew} returns this + */ +proto.services.notifications.v1.CircleGrew.prototype.setCircleType = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional uint32 this_month_circle_size = 3; + * @return {number} + */ +proto.services.notifications.v1.CircleGrew.prototype.getThisMonthCircleSize = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.services.notifications.v1.CircleGrew} returns this + */ +proto.services.notifications.v1.CircleGrew.prototype.setThisMonthCircleSize = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * optional uint32 all_time_circle_size = 4; + * @return {number} + */ +proto.services.notifications.v1.CircleGrew.prototype.getAllTimeCircleSize = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.services.notifications.v1.CircleGrew} returns this + */ +proto.services.notifications.v1.CircleGrew.prototype.setAllTimeCircleSize = function(value) { + return jspb.Message.setProto3IntField(this, 4, 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.CircleThresholdReached.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.CircleThresholdReached.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.CircleThresholdReached} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.CircleThresholdReached.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + circleType: jspb.Message.getFieldWithDefault(msg, 2, 0), + timeFrame: jspb.Message.getFieldWithDefault(msg, 3, 0), + threshold: jspb.Message.getFieldWithDefault(msg, 4, 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.CircleThresholdReached} + */ +proto.services.notifications.v1.CircleThresholdReached.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.CircleThresholdReached; + return proto.services.notifications.v1.CircleThresholdReached.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.CircleThresholdReached} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.CircleThresholdReached} + */ +proto.services.notifications.v1.CircleThresholdReached.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.CircleType} */ (reader.readEnum()); + msg.setCircleType(value); + break; + case 3: + var value = /** @type {!proto.services.notifications.v1.CircleTimeFrame} */ (reader.readEnum()); + msg.setTimeFrame(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint32()); + msg.setThreshold(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.CircleThresholdReached.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.CircleThresholdReached} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.CircleThresholdReached.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getCircleType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getTimeFrame(); + if (f !== 0.0) { + writer.writeEnum( + 3, + f + ); + } + f = message.getThreshold(); + if (f !== 0) { + writer.writeUint32( + 4, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.CircleThresholdReached} returns this + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional CircleType circle_type = 2; + * @return {!proto.services.notifications.v1.CircleType} + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.getCircleType = function() { + return /** @type {!proto.services.notifications.v1.CircleType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.CircleType} value + * @return {!proto.services.notifications.v1.CircleThresholdReached} returns this + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.setCircleType = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional CircleTimeFrame time_frame = 3; + * @return {!proto.services.notifications.v1.CircleTimeFrame} + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.getTimeFrame = function() { + return /** @type {!proto.services.notifications.v1.CircleTimeFrame} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.CircleTimeFrame} value + * @return {!proto.services.notifications.v1.CircleThresholdReached} returns this + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.setTimeFrame = function(value) { + return jspb.Message.setProto3EnumField(this, 3, value); +}; + + +/** + * optional uint32 threshold = 4; + * @return {number} + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.getThreshold = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.services.notifications.v1.CircleThresholdReached} returns this + */ +proto.services.notifications.v1.CircleThresholdReached.prototype.setThreshold = function(value) { + return jspb.Message.setProto3IntField(this, 4, 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.IdentityVerificationApproved.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.IdentityVerificationApproved.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.IdentityVerificationApproved} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.IdentityVerificationApproved.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.IdentityVerificationApproved} + */ +proto.services.notifications.v1.IdentityVerificationApproved.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.IdentityVerificationApproved; + return proto.services.notifications.v1.IdentityVerificationApproved.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.IdentityVerificationApproved} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.IdentityVerificationApproved} + */ +proto.services.notifications.v1.IdentityVerificationApproved.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.IdentityVerificationApproved.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.IdentityVerificationApproved.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.IdentityVerificationApproved} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.IdentityVerificationApproved.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.IdentityVerificationApproved.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.IdentityVerificationApproved} returns this + */ +proto.services.notifications.v1.IdentityVerificationApproved.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.IdentityVerificationDeclined.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.IdentityVerificationDeclined.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.IdentityVerificationDeclined} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.IdentityVerificationDeclined.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + declinedReason: 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.IdentityVerificationDeclined} + */ +proto.services.notifications.v1.IdentityVerificationDeclined.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.IdentityVerificationDeclined; + return proto.services.notifications.v1.IdentityVerificationDeclined.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.IdentityVerificationDeclined} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.IdentityVerificationDeclined} + */ +proto.services.notifications.v1.IdentityVerificationDeclined.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.DeclinedReason} */ (reader.readEnum()); + msg.setDeclinedReason(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.services.notifications.v1.IdentityVerificationDeclined.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.IdentityVerificationDeclined.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.IdentityVerificationDeclined} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.IdentityVerificationDeclined.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getDeclinedReason(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.services.notifications.v1.IdentityVerificationDeclined.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.IdentityVerificationDeclined} returns this + */ +proto.services.notifications.v1.IdentityVerificationDeclined.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional DeclinedReason declined_reason = 2; + * @return {!proto.services.notifications.v1.DeclinedReason} + */ +proto.services.notifications.v1.IdentityVerificationDeclined.prototype.getDeclinedReason = function() { + return /** @type {!proto.services.notifications.v1.DeclinedReason} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.services.notifications.v1.DeclinedReason} value + * @return {!proto.services.notifications.v1.IdentityVerificationDeclined} returns this + */ +proto.services.notifications.v1.IdentityVerificationDeclined.prototype.setDeclinedReason = 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.IdentityVerificationReviewPending.prototype.toObject = function(opt_includeInstance) { + return proto.services.notifications.v1.IdentityVerificationReviewPending.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.IdentityVerificationReviewPending} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.IdentityVerificationReviewPending.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.IdentityVerificationReviewPending} + */ +proto.services.notifications.v1.IdentityVerificationReviewPending.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.services.notifications.v1.IdentityVerificationReviewPending; + return proto.services.notifications.v1.IdentityVerificationReviewPending.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.services.notifications.v1.IdentityVerificationReviewPending} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.services.notifications.v1.IdentityVerificationReviewPending} + */ +proto.services.notifications.v1.IdentityVerificationReviewPending.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.IdentityVerificationReviewPending.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.services.notifications.v1.IdentityVerificationReviewPending.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.IdentityVerificationReviewPending} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.services.notifications.v1.IdentityVerificationReviewPending.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.IdentityVerificationReviewPending.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.services.notifications.v1.IdentityVerificationReviewPending} returns this + */ +proto.services.notifications.v1.IdentityVerificationReviewPending.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * @enum {number} + */ +proto.services.notifications.v1.NotificationChannel = { + PUSH: 0 +}; + +/** + * @enum {number} + */ +proto.services.notifications.v1.NotificationCategory = { + CIRCLES: 0, + PAYMENTS: 1, + BALANCE: 2, + ADMIN_NOTIFICATION: 3 +}; + +/** + * @enum {number} + */ +proto.services.notifications.v1.CircleType = { + INNER: 0, + OUTER: 1 +}; + +/** + * @enum {number} + */ +proto.services.notifications.v1.CircleTimeFrame = { + MONTH: 0, + ALL_TIME: 1 +}; + +/** + * @enum {number} + */ +proto.services.notifications.v1.DeclinedReason = { + DOCUMENTS_NOT_CLEAR: 0, + VERIFICATION_PHOTO_NOT_CLEAR: 1 }; goog.object.extend(exports, proto.services.notifications.v1); diff --git a/core/notifications/proto/notifications.proto b/core/notifications/proto/notifications.proto index 8298a7be4a..5e9fe5184c 100644 --- a/core/notifications/proto/notifications.proto +++ b/core/notifications/proto/notifications.proto @@ -14,6 +14,8 @@ service NotificationsService { rpc UpdateUserLocale (UpdateUserLocaleRequest) returns (UpdateUserLocaleResponse) {} rpc AddPushDeviceToken (AddPushDeviceTokenRequest) returns (AddPushDeviceTokenResponse) {} rpc RemovePushDeviceToken (RemovePushDeviceTokenRequest) returns (RemovePushDeviceTokenResponse) {} + rpc UpdateEmailAddress (UpdateEmailAddressRequest) returns (UpdateEmailAddressResponse) {} + rpc RemoveEmailAddress (RemoveEmailAddressRequest) returns (RemoveEmailAddressResponse) {} rpc HandleNotificationEvent (HandleNotificationEventRequest) returns (HandleNotificationEventResponse) {} } @@ -123,6 +125,19 @@ message RemovePushDeviceTokenResponse { NotificationSettings notification_settings = 1; } +message UpdateEmailAddressRequest { + string user_id = 1; + string email_address = 2; +} + +message UpdateEmailAddressResponse { } + +message RemoveEmailAddressRequest { + string user_id = 1; +} + +message RemoveEmailAddressResponse { } + message HandleNotificationEventRequest { NotificationEvent event = 1; } diff --git a/core/notifications/src/app/mod.rs b/core/notifications/src/app/mod.rs index fd3ade9a6b..f6ca62e049 100644 --- a/core/notifications/src/app/mod.rs +++ b/core/notifications/src/app/mod.rs @@ -147,6 +147,26 @@ impl NotificationsApp { Ok(user_settings) } + #[instrument(name = "app.update_email_address", skip(self), err)] + pub async fn update_email_address( + &self, + user_id: GaloyUserId, + addr: GaloyEmailAddress, + ) -> Result<(), ApplicationError> { + let mut user_settings = self.settings.find_for_user_id(&user_id).await?; + user_settings.update_email_address(addr); + self.settings.persist(&mut user_settings).await?; + Ok(()) + } + + #[instrument(name = "app.remove_email_address", skip(self), err)] + pub async fn remove_email_address(&self, user_id: GaloyUserId) -> Result<(), ApplicationError> { + let mut user_settings = self.settings.find_for_user_id(&user_id).await?; + user_settings.remove_email_address(); + self.settings.persist(&mut user_settings).await?; + Ok(()) + } + #[instrument(name = "app.handle_notification_event", skip(self), err)] pub async fn handle_notification_event( &self, diff --git a/core/notifications/src/grpc/server/mod.rs b/core/notifications/src/grpc/server/mod.rs index b40b36060a..0330168b43 100644 --- a/core/notifications/src/grpc/server/mod.rs +++ b/core/notifications/src/grpc/server/mod.rs @@ -15,7 +15,8 @@ use crate::{ app::*, notification_event, primitives::{ - self, GaloyUserId, PushDeviceToken, UserNotificationCategory, UserNotificationChannel, + self, GaloyEmailAddress, GaloyUserId, PushDeviceToken, UserNotificationCategory, + UserNotificationChannel, }, }; @@ -228,6 +229,38 @@ impl NotificationsService for Notifications { })) } + #[instrument(name = "notifications.update_email_address", skip_all, err)] + async fn update_email_address( + &self, + request: Request, + ) -> Result, Status> { + grpc::extract_tracing(&request); + let request = request.into_inner(); + let UpdateEmailAddressRequest { + user_id, + email_address, + } = request; + let user_id = GaloyUserId::from(user_id); + let addr = GaloyEmailAddress::from(email_address); + self.app.update_email_address(user_id, addr).await?; + + Ok(Response::new(UpdateEmailAddressResponse {})) + } + + #[instrument(name = "notifications.remove_email_address", skip_all, err)] + async fn remove_email_address( + &self, + request: Request, + ) -> Result, Status> { + grpc::extract_tracing(&request); + let request = request.into_inner(); + let RemoveEmailAddressRequest { user_id } = request; + let user_id = GaloyUserId::from(user_id); + self.app.remove_email_address(user_id).await?; + + Ok(Response::new(RemoveEmailAddressResponse {})) + } + #[instrument(name = "notifications.handle_notification_event", skip_all, err)] async fn handle_notification_event( &self, diff --git a/core/notifications/src/primitives.rs b/core/notifications/src/primitives.rs index db2cdda597..1fec7bece2 100644 --- a/core/notifications/src/primitives.rs +++ b/core/notifications/src/primitives.rs @@ -80,6 +80,31 @@ impl std::fmt::Display for PushDeviceToken { } } +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Hash)] +pub struct GaloyEmailAddress(String); +impl GaloyEmailAddress { + pub fn into_inner(self) -> String { + self.0 + } +} +impl From for GaloyEmailAddress { + fn from(s: String) -> Self { + Self(s) + } +} + +impl AsRef for GaloyEmailAddress { + fn as_ref(&self) -> &str { + &self.0 + } +} + +impl std::fmt::Display for GaloyEmailAddress { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + #[derive(async_graphql::Enum, Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize)] #[graphql(name = "UserNotificationChannel")] pub enum UserNotificationChannel { diff --git a/core/notifications/src/user_notification_settings/entity.rs b/core/notifications/src/user_notification_settings/entity.rs index a72f631e74..d742449692 100644 --- a/core/notifications/src/user_notification_settings/entity.rs +++ b/core/notifications/src/user_notification_settings/entity.rs @@ -37,6 +37,12 @@ pub enum UserNotificationSettingsEvent { PushDeviceTokenRemoved { token: PushDeviceToken, }, + EmailAddressAdded { + addr: GaloyEmailAddress, + }, + EmailAddressRemoved { + addr: GaloyEmailAddress, + }, } impl EntityEvent for UserNotificationSettingsEvent { @@ -210,6 +216,40 @@ impl UserNotificationSettings { self.events .push(UserNotificationSettingsEvent::PushDeviceTokenRemoved { token }) } + + pub fn email_address(&self) -> Option { + self.events.iter().fold(None, |mut acc, event| { + match event { + UserNotificationSettingsEvent::EmailAddressAdded { addr } => { + acc = Some(addr.clone()); + } + UserNotificationSettingsEvent::EmailAddressRemoved { .. } => { + acc = None; + } + _ => (), + } + acc + }) + } + + pub fn update_email_address(&mut self, addr: GaloyEmailAddress) { + match self.email_address() { + Some(existing) if existing == addr => return, + None => (), + Some(addr) => self + .events + .push(UserNotificationSettingsEvent::EmailAddressRemoved { addr }), + } + self.events + .push(UserNotificationSettingsEvent::EmailAddressAdded { addr }); + } + + pub fn remove_email_address(&mut self) { + if let Some(addr) = self.email_address() { + self.events + .push(UserNotificationSettingsEvent::EmailAddressRemoved { addr }) + } + } } impl TryFrom> for UserNotificationSettings { @@ -385,4 +425,22 @@ mod tests { HashSet::from([PushDeviceToken::from("token2".to_string())]) ); } + + #[test] + fn can_update_and_remove_emails() { + let events = initial_events(); + let mut settings = UserNotificationSettings::try_from(events).expect("Could not hydrate"); + assert_eq!(settings.email_address(), None); + + let addr = GaloyEmailAddress::from("email@test.com".to_string()); + settings.update_email_address(addr.clone()); + assert_eq!(settings.email_address(), Some(addr)); + + let addr = GaloyEmailAddress::from("email-2@test.com".to_string()); + settings.update_email_address(addr.clone()); + assert_eq!(settings.email_address(), Some(addr)); + + settings.remove_email_address(); + assert_eq!(settings.email_address(), None); + } }