diff --git a/src/core/engines/gows/appstate.ts b/src/core/engines/gows/appstate.ts new file mode 100644 index 00000000..a52c857c --- /dev/null +++ b/src/core/engines/gows/appstate.ts @@ -0,0 +1,3 @@ +export function isFromFullSync(event: any): boolean { + return event.FromFullSync; +} diff --git a/src/core/engines/gows/grpc/gows.ts b/src/core/engines/gows/grpc/gows.ts index 36d92053..792ebad0 100644 --- a/src/core/engines/gows/grpc/gows.ts +++ b/src/core/engines/gows/grpc/gows.ts @@ -7603,6 +7603,497 @@ export namespace messages { return GetChatsRequest.deserialize(bytes); } } + export class GetLabelsRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + session?: Session; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("session" in data && data.session != undefined) { + this.session = data.session; + } + } + } + get session() { + return pb_1.Message.getWrapperField(this, Session, 1) as Session; + } + set session(value: Session) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_session() { + return pb_1.Message.getField(this, 1) != null; + } + static fromObject(data: { + session?: ReturnType; + }): GetLabelsRequest { + const message = new GetLabelsRequest({}); + if (data.session != null) { + message.session = Session.fromObject(data.session); + } + return message; + } + toObject() { + const data: { + session?: ReturnType; + } = {}; + if (this.session != null) { + data.session = this.session.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_session) + writer.writeMessage(1, this.session, () => this.session.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GetLabelsRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GetLabelsRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.session, () => message.session = Session.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): GetLabelsRequest { + return GetLabelsRequest.deserialize(bytes); + } + } + export class Label extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + name?: string; + color?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("id" in data && data.id != undefined) { + this.id = data.id; + } + if ("name" in data && data.name != undefined) { + this.name = data.name; + } + if ("color" in data && data.color != undefined) { + this.color = data.color; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get name() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set name(value: string) { + pb_1.Message.setField(this, 2, value); + } + get color() { + return pb_1.Message.getFieldWithDefault(this, 4, 0) as number; + } + set color(value: number) { + pb_1.Message.setField(this, 4, value); + } + static fromObject(data: { + id?: string; + name?: string; + color?: number; + }): Label { + const message = new Label({}); + if (data.id != null) { + message.id = data.id; + } + if (data.name != null) { + message.name = data.name; + } + if (data.color != null) { + message.color = data.color; + } + return message; + } + toObject() { + const data: { + id?: string; + name?: string; + color?: number; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.name != null) { + data.name = this.name; + } + if (this.color != null) { + data.color = this.color; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.id.length) + writer.writeString(1, this.id); + if (this.name.length) + writer.writeString(2, this.name); + if (this.color != 0) + writer.writeInt32(4, this.color); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Label { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Label(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.name = reader.readString(); + break; + case 4: + message.color = reader.readInt32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Label { + return Label.deserialize(bytes); + } + } + export class UpsertLabelRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + session?: Session; + label?: Label; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("session" in data && data.session != undefined) { + this.session = data.session; + } + if ("label" in data && data.label != undefined) { + this.label = data.label; + } + } + } + get session() { + return pb_1.Message.getWrapperField(this, Session, 1) as Session; + } + set session(value: Session) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_session() { + return pb_1.Message.getField(this, 1) != null; + } + get label() { + return pb_1.Message.getWrapperField(this, Label, 2) as Label; + } + set label(value: Label) { + pb_1.Message.setWrapperField(this, 2, value); + } + get has_label() { + return pb_1.Message.getField(this, 2) != null; + } + static fromObject(data: { + session?: ReturnType; + label?: ReturnType; + }): UpsertLabelRequest { + const message = new UpsertLabelRequest({}); + if (data.session != null) { + message.session = Session.fromObject(data.session); + } + if (data.label != null) { + message.label = Label.fromObject(data.label); + } + return message; + } + toObject() { + const data: { + session?: ReturnType; + label?: ReturnType; + } = {}; + if (this.session != null) { + data.session = this.session.toObject(); + } + if (this.label != null) { + data.label = this.label.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_session) + writer.writeMessage(1, this.session, () => this.session.serialize(writer)); + if (this.has_label) + writer.writeMessage(2, this.label, () => this.label.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): UpsertLabelRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new UpsertLabelRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.session, () => message.session = Session.deserialize(reader)); + break; + case 2: + reader.readMessage(message.label, () => message.label = Label.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): UpsertLabelRequest { + return UpsertLabelRequest.deserialize(bytes); + } + } + export class DeleteLabelRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + session?: Session; + label?: Label; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("session" in data && data.session != undefined) { + this.session = data.session; + } + if ("label" in data && data.label != undefined) { + this.label = data.label; + } + } + } + get session() { + return pb_1.Message.getWrapperField(this, Session, 1) as Session; + } + set session(value: Session) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_session() { + return pb_1.Message.getField(this, 1) != null; + } + get label() { + return pb_1.Message.getWrapperField(this, Label, 2) as Label; + } + set label(value: Label) { + pb_1.Message.setWrapperField(this, 2, value); + } + get has_label() { + return pb_1.Message.getField(this, 2) != null; + } + static fromObject(data: { + session?: ReturnType; + label?: ReturnType; + }): DeleteLabelRequest { + const message = new DeleteLabelRequest({}); + if (data.session != null) { + message.session = Session.fromObject(data.session); + } + if (data.label != null) { + message.label = Label.fromObject(data.label); + } + return message; + } + toObject() { + const data: { + session?: ReturnType; + label?: ReturnType; + } = {}; + if (this.session != null) { + data.session = this.session.toObject(); + } + if (this.label != null) { + data.label = this.label.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_session) + writer.writeMessage(1, this.session, () => this.session.serialize(writer)); + if (this.has_label) + writer.writeMessage(2, this.label, () => this.label.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DeleteLabelRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DeleteLabelRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.session, () => message.session = Session.deserialize(reader)); + break; + case 2: + reader.readMessage(message.label, () => message.label = Label.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): DeleteLabelRequest { + return DeleteLabelRequest.deserialize(bytes); + } + } + export class ChatLabelRequest extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + session?: Session; + chatId?: string; + labelId?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("session" in data && data.session != undefined) { + this.session = data.session; + } + if ("chatId" in data && data.chatId != undefined) { + this.chatId = data.chatId; + } + if ("labelId" in data && data.labelId != undefined) { + this.labelId = data.labelId; + } + } + } + get session() { + return pb_1.Message.getWrapperField(this, Session, 1) as Session; + } + set session(value: Session) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_session() { + return pb_1.Message.getField(this, 1) != null; + } + get chatId() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set chatId(value: string) { + pb_1.Message.setField(this, 2, value); + } + get labelId() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + } + set labelId(value: string) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + session?: ReturnType; + chatId?: string; + labelId?: string; + }): ChatLabelRequest { + const message = new ChatLabelRequest({}); + if (data.session != null) { + message.session = Session.fromObject(data.session); + } + if (data.chatId != null) { + message.chatId = data.chatId; + } + if (data.labelId != null) { + message.labelId = data.labelId; + } + return message; + } + toObject() { + const data: { + session?: ReturnType; + chatId?: string; + labelId?: string; + } = {}; + if (this.session != null) { + data.session = this.session.toObject(); + } + if (this.chatId != null) { + data.chatId = this.chatId; + } + if (this.labelId != null) { + data.labelId = this.labelId; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_session) + writer.writeMessage(1, this.session, () => this.session.serialize(writer)); + if (this.chatId.length) + writer.writeString(2, this.chatId); + if (this.labelId.length) + writer.writeString(3, this.labelId); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ChatLabelRequest { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ChatLabelRequest(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.session, () => message.session = Session.deserialize(reader)); + break; + case 2: + message.chatId = reader.readString(); + break; + case 3: + message.labelId = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): ChatLabelRequest { + return ChatLabelRequest.deserialize(bytes); + } + } interface GrpcUnaryServiceInterface { (message: P, metadata: grpc_1.Metadata, options: grpc_1.CallOptions, callback: grpc_1.requestCallback): grpc_1.ClientUnaryCall; (message: P, metadata: grpc_1.Metadata, callback: grpc_1.requestCallback): grpc_1.ClientUnaryCall; @@ -8039,6 +8530,69 @@ export namespace messages { responseSerialize: (message: Empty) => Buffer.from(message.serialize()), responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes)) }, + GetLabels: { + path: "/messages.MessageService/GetLabels", + requestStream: false, + responseStream: false, + requestSerialize: (message: GetLabelsRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => GetLabelsRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: JsonList) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => JsonList.deserialize(new Uint8Array(bytes)) + }, + UpsertLabel: { + path: "/messages.MessageService/UpsertLabel", + requestStream: false, + responseStream: false, + requestSerialize: (message: UpsertLabelRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => UpsertLabelRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: Empty) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes)) + }, + DeleteLabel: { + path: "/messages.MessageService/DeleteLabel", + requestStream: false, + responseStream: false, + requestSerialize: (message: DeleteLabelRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => DeleteLabelRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: Empty) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes)) + }, + AddChatLabel: { + path: "/messages.MessageService/AddChatLabel", + requestStream: false, + responseStream: false, + requestSerialize: (message: ChatLabelRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => ChatLabelRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: Empty) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes)) + }, + RemoveChatLabel: { + path: "/messages.MessageService/RemoveChatLabel", + requestStream: false, + responseStream: false, + requestSerialize: (message: ChatLabelRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => ChatLabelRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: Empty) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes)) + }, + GetLabelsByJid: { + path: "/messages.MessageService/GetLabelsByJid", + requestStream: false, + responseStream: false, + requestSerialize: (message: EntityByIdRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => EntityByIdRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: JsonList) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => JsonList.deserialize(new Uint8Array(bytes)) + }, + GetChatsByLabelId: { + path: "/messages.MessageService/GetChatsByLabelId", + requestStream: false, + responseStream: false, + requestSerialize: (message: EntityByIdRequest) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => EntityByIdRequest.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: JsonList) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => JsonList.deserialize(new Uint8Array(bytes)) + }, DownloadMedia: { path: "/messages.MessageService/DownloadMedia", requestStream: false, @@ -8138,6 +8692,13 @@ export namespace messages { abstract CreateNewsletter(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract NewsletterToggleMute(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract NewsletterToggleFollow(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetLabels(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract UpsertLabel(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract DeleteLabel(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract AddChatLabel(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract RemoveChatLabel(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetLabelsByJid(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetChatsByLabelId(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract DownloadMedia(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract GetMessageById(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract GetMessages(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; @@ -8278,6 +8839,27 @@ export namespace messages { NewsletterToggleFollow: GrpcUnaryServiceInterface = (message: NewsletterToggleFollowRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.NewsletterToggleFollow(message, metadata, options, callback); }; + GetLabels: GrpcUnaryServiceInterface = (message: GetLabelsRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.GetLabels(message, metadata, options, callback); + }; + UpsertLabel: GrpcUnaryServiceInterface = (message: UpsertLabelRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.UpsertLabel(message, metadata, options, callback); + }; + DeleteLabel: GrpcUnaryServiceInterface = (message: DeleteLabelRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.DeleteLabel(message, metadata, options, callback); + }; + AddChatLabel: GrpcUnaryServiceInterface = (message: ChatLabelRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.AddChatLabel(message, metadata, options, callback); + }; + RemoveChatLabel: GrpcUnaryServiceInterface = (message: ChatLabelRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.RemoveChatLabel(message, metadata, options, callback); + }; + GetLabelsByJid: GrpcUnaryServiceInterface = (message: EntityByIdRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.GetLabelsByJid(message, metadata, options, callback); + }; + GetChatsByLabelId: GrpcUnaryServiceInterface = (message: EntityByIdRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.GetChatsByLabelId(message, metadata, options, callback); + }; DownloadMedia: GrpcUnaryServiceInterface = (message: DownloadMediaRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.DownloadMedia(message, metadata, options, callback); }; diff --git a/src/core/engines/gows/grpc/gows_grpc_pb.js b/src/core/engines/gows/grpc/gows_grpc_pb.js index 79e68291..28226914 100644 --- a/src/core/engines/gows/grpc/gows_grpc_pb.js +++ b/src/core/engines/gows/grpc/gows_grpc_pb.js @@ -15,6 +15,17 @@ function deserialize_messages_ButtonReplyRequest(buffer_arg) { return gows_pb.ButtonReplyRequest.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_messages_ChatLabelRequest(arg) { + if (!(arg instanceof gows_pb.ChatLabelRequest)) { + throw new Error('Expected argument of type messages.ChatLabelRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_messages_ChatLabelRequest(buffer_arg) { + return gows_pb.ChatLabelRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_messages_ChatPresenceRequest(arg) { if (!(arg instanceof gows_pb.ChatPresenceRequest)) { throw new Error('Expected argument of type messages.ChatPresenceRequest'); @@ -70,6 +81,17 @@ function deserialize_messages_CreateNewsletterRequest(buffer_arg) { return gows_pb.CreateNewsletterRequest.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_messages_DeleteLabelRequest(arg) { + if (!(arg instanceof gows_pb.DeleteLabelRequest)) { + throw new Error('Expected argument of type messages.DeleteLabelRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_messages_DeleteLabelRequest(buffer_arg) { + return gows_pb.DeleteLabelRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_messages_DownloadMediaRequest(arg) { if (!(arg instanceof gows_pb.DownloadMediaRequest)) { throw new Error('Expected argument of type messages.DownloadMediaRequest'); @@ -158,6 +180,17 @@ function deserialize_messages_GetContactsRequest(buffer_arg) { return gows_pb.GetContactsRequest.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_messages_GetLabelsRequest(arg) { + if (!(arg instanceof gows_pb.GetLabelsRequest)) { + throw new Error('Expected argument of type messages.GetLabelsRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_messages_GetLabelsRequest(buffer_arg) { + return gows_pb.GetLabelsRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_messages_GetMessagesRequest(arg) { if (!(arg instanceof gows_pb.GetMessagesRequest)) { throw new Error('Expected argument of type messages.GetMessagesRequest'); @@ -576,6 +609,17 @@ function deserialize_messages_UpdateParticipantsRequest(buffer_arg) { return gows_pb.UpdateParticipantsRequest.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_messages_UpsertLabelRequest(arg) { + if (!(arg instanceof gows_pb.UpsertLabelRequest)) { + throw new Error('Expected argument of type messages.UpsertLabelRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_messages_UpsertLabelRequest(buffer_arg) { + return gows_pb.UpsertLabelRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + // // Events @@ -1090,6 +1134,86 @@ getSubscribedNewsletters: { responseDeserialize: deserialize_messages_Empty, }, // +// Labels +// +getLabels: { + path: '/messages.MessageService/GetLabels', + requestStream: false, + responseStream: false, + requestType: gows_pb.GetLabelsRequest, + responseType: gows_pb.JsonList, + requestSerialize: serialize_messages_GetLabelsRequest, + requestDeserialize: deserialize_messages_GetLabelsRequest, + responseSerialize: serialize_messages_JsonList, + responseDeserialize: deserialize_messages_JsonList, + }, + upsertLabel: { + path: '/messages.MessageService/UpsertLabel', + requestStream: false, + responseStream: false, + requestType: gows_pb.UpsertLabelRequest, + responseType: gows_pb.Empty, + requestSerialize: serialize_messages_UpsertLabelRequest, + requestDeserialize: deserialize_messages_UpsertLabelRequest, + responseSerialize: serialize_messages_Empty, + responseDeserialize: deserialize_messages_Empty, + }, + deleteLabel: { + path: '/messages.MessageService/DeleteLabel', + requestStream: false, + responseStream: false, + requestType: gows_pb.DeleteLabelRequest, + responseType: gows_pb.Empty, + requestSerialize: serialize_messages_DeleteLabelRequest, + requestDeserialize: deserialize_messages_DeleteLabelRequest, + responseSerialize: serialize_messages_Empty, + responseDeserialize: deserialize_messages_Empty, + }, + addChatLabel: { + path: '/messages.MessageService/AddChatLabel', + requestStream: false, + responseStream: false, + requestType: gows_pb.ChatLabelRequest, + responseType: gows_pb.Empty, + requestSerialize: serialize_messages_ChatLabelRequest, + requestDeserialize: deserialize_messages_ChatLabelRequest, + responseSerialize: serialize_messages_Empty, + responseDeserialize: deserialize_messages_Empty, + }, + removeChatLabel: { + path: '/messages.MessageService/RemoveChatLabel', + requestStream: false, + responseStream: false, + requestType: gows_pb.ChatLabelRequest, + responseType: gows_pb.Empty, + requestSerialize: serialize_messages_ChatLabelRequest, + requestDeserialize: deserialize_messages_ChatLabelRequest, + responseSerialize: serialize_messages_Empty, + responseDeserialize: deserialize_messages_Empty, + }, + getLabelsByJid: { + path: '/messages.MessageService/GetLabelsByJid', + requestStream: false, + responseStream: false, + requestType: gows_pb.EntityByIdRequest, + responseType: gows_pb.JsonList, + requestSerialize: serialize_messages_EntityByIdRequest, + requestDeserialize: deserialize_messages_EntityByIdRequest, + responseSerialize: serialize_messages_JsonList, + responseDeserialize: deserialize_messages_JsonList, + }, + getChatsByLabelId: { + path: '/messages.MessageService/GetChatsByLabelId', + requestStream: false, + responseStream: false, + requestType: gows_pb.EntityByIdRequest, + responseType: gows_pb.JsonList, + requestSerialize: serialize_messages_EntityByIdRequest, + requestDeserialize: deserialize_messages_EntityByIdRequest, + responseSerialize: serialize_messages_JsonList, + responseDeserialize: deserialize_messages_JsonList, + }, + // // Media // downloadMedia: { diff --git a/src/core/engines/gows/grpc/gows_pb.js b/src/core/engines/gows/grpc/gows_pb.js index 434e9bcd..54d6392e 100644 --- a/src/core/engines/gows/grpc/gows_pb.js +++ b/src/core/engines/gows/grpc/gows_pb.js @@ -23,12 +23,14 @@ var global = (function() { goog.exportSymbol('proto.messages.AudioInfo', null, global); goog.exportSymbol('proto.messages.ButtonReplyRequest', null, global); +goog.exportSymbol('proto.messages.ChatLabelRequest', null, global); goog.exportSymbol('proto.messages.ChatPresence', null, global); goog.exportSymbol('proto.messages.ChatPresenceRequest', null, global); goog.exportSymbol('proto.messages.CheckPhonesRequest', null, global); goog.exportSymbol('proto.messages.CheckPhonesResponse', null, global); goog.exportSymbol('proto.messages.CreateGroupRequest', null, global); goog.exportSymbol('proto.messages.CreateNewsletterRequest', null, global); +goog.exportSymbol('proto.messages.DeleteLabelRequest', null, global); goog.exportSymbol('proto.messages.DownloadMediaRequest', null, global); goog.exportSymbol('proto.messages.DownloadMediaResponse', null, global); goog.exportSymbol('proto.messages.EditMessageRequest', null, global); @@ -37,6 +39,7 @@ goog.exportSymbol('proto.messages.EntityByIdRequest', null, global); goog.exportSymbol('proto.messages.EventJson', null, global); goog.exportSymbol('proto.messages.GetChatsRequest', null, global); goog.exportSymbol('proto.messages.GetContactsRequest', null, global); +goog.exportSymbol('proto.messages.GetLabelsRequest', null, global); goog.exportSymbol('proto.messages.GetMessagesRequest', null, global); goog.exportSymbol('proto.messages.GetNewsletterMessagesByInviteRequest', null, global); goog.exportSymbol('proto.messages.GroupCodeRequest', null, global); @@ -45,6 +48,7 @@ goog.exportSymbol('proto.messages.JidRequest', null, global); goog.exportSymbol('proto.messages.JidStringRequest', null, global); goog.exportSymbol('proto.messages.Json', null, global); goog.exportSymbol('proto.messages.JsonList', null, global); +goog.exportSymbol('proto.messages.Label', null, global); goog.exportSymbol('proto.messages.LinkPreview', null, global); goog.exportSymbol('proto.messages.LogLevel', null, global); goog.exportSymbol('proto.messages.MarkReadRequest', null, global); @@ -96,6 +100,7 @@ goog.exportSymbol('proto.messages.SortBy.Order', null, global); goog.exportSymbol('proto.messages.StartSessionRequest', null, global); goog.exportSymbol('proto.messages.SubscribePresenceRequest', null, global); goog.exportSymbol('proto.messages.UpdateParticipantsRequest', null, global); +goog.exportSymbol('proto.messages.UpsertLabelRequest', null, global); goog.exportSymbol('proto.messages.vCardContact', null, global); /** * Generated by JsPbCodeGenerator. @@ -1546,6 +1551,111 @@ if (goog.DEBUG && !COMPILED) { */ proto.messages.GetChatsRequest.displayName = 'proto.messages.GetChatsRequest'; } +/** + * 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.messages.GetLabelsRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.messages.GetLabelsRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.messages.GetLabelsRequest.displayName = 'proto.messages.GetLabelsRequest'; +} +/** + * 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.messages.Label = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.messages.Label, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.messages.Label.displayName = 'proto.messages.Label'; +} +/** + * 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.messages.UpsertLabelRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.messages.UpsertLabelRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.messages.UpsertLabelRequest.displayName = 'proto.messages.UpsertLabelRequest'; +} +/** + * 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.messages.DeleteLabelRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.messages.DeleteLabelRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.messages.DeleteLabelRequest.displayName = 'proto.messages.DeleteLabelRequest'; +} +/** + * 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.messages.ChatLabelRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.messages.ChatLabelRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.messages.ChatLabelRequest.displayName = 'proto.messages.ChatLabelRequest'; +} @@ -15893,6 +16003,962 @@ proto.messages.GetChatsRequest.prototype.hasPagination = function() { }; + + + +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.messages.GetLabelsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.messages.GetLabelsRequest.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.messages.GetLabelsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.GetLabelsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + session: (f = msg.getSession()) && proto.messages.Session.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.messages.GetLabelsRequest} + */ +proto.messages.GetLabelsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.messages.GetLabelsRequest; + return proto.messages.GetLabelsRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.messages.GetLabelsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.messages.GetLabelsRequest} + */ +proto.messages.GetLabelsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.messages.Session; + reader.readMessage(value,proto.messages.Session.deserializeBinaryFromReader); + msg.setSession(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.messages.GetLabelsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.messages.GetLabelsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.messages.GetLabelsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.GetLabelsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSession(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.messages.Session.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Session session = 1; + * @return {?proto.messages.Session} + */ +proto.messages.GetLabelsRequest.prototype.getSession = function() { + return /** @type{?proto.messages.Session} */ ( + jspb.Message.getWrapperField(this, proto.messages.Session, 1)); +}; + + +/** + * @param {?proto.messages.Session|undefined} value + * @return {!proto.messages.GetLabelsRequest} returns this +*/ +proto.messages.GetLabelsRequest.prototype.setSession = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.messages.GetLabelsRequest} returns this + */ +proto.messages.GetLabelsRequest.prototype.clearSession = function() { + return this.setSession(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.messages.GetLabelsRequest.prototype.hasSession = 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.messages.Label.prototype.toObject = function(opt_includeInstance) { + return proto.messages.Label.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.messages.Label} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.Label.toObject = function(includeInstance, msg) { + var f, obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, ""), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), + color: 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.messages.Label} + */ +proto.messages.Label.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.messages.Label; + return proto.messages.Label.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.messages.Label} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.messages.Label} + */ +proto.messages.Label.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.setId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 4: + var value = /** @type {number} */ (reader.readInt32()); + msg.setColor(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.messages.Label.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.messages.Label.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.messages.Label} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.Label.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getColor(); + if (f !== 0) { + writer.writeInt32( + 4, + f + ); + } +}; + + +/** + * optional string id = 1; + * @return {string} + */ +proto.messages.Label.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.messages.Label} returns this + */ +proto.messages.Label.prototype.setId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string name = 2; + * @return {string} + */ +proto.messages.Label.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.messages.Label} returns this + */ +proto.messages.Label.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional int32 color = 4; + * @return {number} + */ +proto.messages.Label.prototype.getColor = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.messages.Label} returns this + */ +proto.messages.Label.prototype.setColor = 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.messages.UpsertLabelRequest.prototype.toObject = function(opt_includeInstance) { + return proto.messages.UpsertLabelRequest.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.messages.UpsertLabelRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.UpsertLabelRequest.toObject = function(includeInstance, msg) { + var f, obj = { + session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f), + label: (f = msg.getLabel()) && proto.messages.Label.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.messages.UpsertLabelRequest} + */ +proto.messages.UpsertLabelRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.messages.UpsertLabelRequest; + return proto.messages.UpsertLabelRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.messages.UpsertLabelRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.messages.UpsertLabelRequest} + */ +proto.messages.UpsertLabelRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.messages.Session; + reader.readMessage(value,proto.messages.Session.deserializeBinaryFromReader); + msg.setSession(value); + break; + case 2: + var value = new proto.messages.Label; + reader.readMessage(value,proto.messages.Label.deserializeBinaryFromReader); + msg.setLabel(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.messages.UpsertLabelRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.messages.UpsertLabelRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.messages.UpsertLabelRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.UpsertLabelRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSession(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.messages.Session.serializeBinaryToWriter + ); + } + f = message.getLabel(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.messages.Label.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Session session = 1; + * @return {?proto.messages.Session} + */ +proto.messages.UpsertLabelRequest.prototype.getSession = function() { + return /** @type{?proto.messages.Session} */ ( + jspb.Message.getWrapperField(this, proto.messages.Session, 1)); +}; + + +/** + * @param {?proto.messages.Session|undefined} value + * @return {!proto.messages.UpsertLabelRequest} returns this +*/ +proto.messages.UpsertLabelRequest.prototype.setSession = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.messages.UpsertLabelRequest} returns this + */ +proto.messages.UpsertLabelRequest.prototype.clearSession = function() { + return this.setSession(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.messages.UpsertLabelRequest.prototype.hasSession = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Label label = 2; + * @return {?proto.messages.Label} + */ +proto.messages.UpsertLabelRequest.prototype.getLabel = function() { + return /** @type{?proto.messages.Label} */ ( + jspb.Message.getWrapperField(this, proto.messages.Label, 2)); +}; + + +/** + * @param {?proto.messages.Label|undefined} value + * @return {!proto.messages.UpsertLabelRequest} returns this +*/ +proto.messages.UpsertLabelRequest.prototype.setLabel = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.messages.UpsertLabelRequest} returns this + */ +proto.messages.UpsertLabelRequest.prototype.clearLabel = function() { + return this.setLabel(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.messages.UpsertLabelRequest.prototype.hasLabel = function() { + return jspb.Message.getField(this, 2) != 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.messages.DeleteLabelRequest.prototype.toObject = function(opt_includeInstance) { + return proto.messages.DeleteLabelRequest.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.messages.DeleteLabelRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.DeleteLabelRequest.toObject = function(includeInstance, msg) { + var f, obj = { + session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f), + label: (f = msg.getLabel()) && proto.messages.Label.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.messages.DeleteLabelRequest} + */ +proto.messages.DeleteLabelRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.messages.DeleteLabelRequest; + return proto.messages.DeleteLabelRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.messages.DeleteLabelRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.messages.DeleteLabelRequest} + */ +proto.messages.DeleteLabelRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.messages.Session; + reader.readMessage(value,proto.messages.Session.deserializeBinaryFromReader); + msg.setSession(value); + break; + case 2: + var value = new proto.messages.Label; + reader.readMessage(value,proto.messages.Label.deserializeBinaryFromReader); + msg.setLabel(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.messages.DeleteLabelRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.messages.DeleteLabelRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.messages.DeleteLabelRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.DeleteLabelRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSession(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.messages.Session.serializeBinaryToWriter + ); + } + f = message.getLabel(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.messages.Label.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Session session = 1; + * @return {?proto.messages.Session} + */ +proto.messages.DeleteLabelRequest.prototype.getSession = function() { + return /** @type{?proto.messages.Session} */ ( + jspb.Message.getWrapperField(this, proto.messages.Session, 1)); +}; + + +/** + * @param {?proto.messages.Session|undefined} value + * @return {!proto.messages.DeleteLabelRequest} returns this +*/ +proto.messages.DeleteLabelRequest.prototype.setSession = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.messages.DeleteLabelRequest} returns this + */ +proto.messages.DeleteLabelRequest.prototype.clearSession = function() { + return this.setSession(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.messages.DeleteLabelRequest.prototype.hasSession = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Label label = 2; + * @return {?proto.messages.Label} + */ +proto.messages.DeleteLabelRequest.prototype.getLabel = function() { + return /** @type{?proto.messages.Label} */ ( + jspb.Message.getWrapperField(this, proto.messages.Label, 2)); +}; + + +/** + * @param {?proto.messages.Label|undefined} value + * @return {!proto.messages.DeleteLabelRequest} returns this +*/ +proto.messages.DeleteLabelRequest.prototype.setLabel = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.messages.DeleteLabelRequest} returns this + */ +proto.messages.DeleteLabelRequest.prototype.clearLabel = function() { + return this.setLabel(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.messages.DeleteLabelRequest.prototype.hasLabel = function() { + return jspb.Message.getField(this, 2) != 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.messages.ChatLabelRequest.prototype.toObject = function(opt_includeInstance) { + return proto.messages.ChatLabelRequest.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.messages.ChatLabelRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.ChatLabelRequest.toObject = function(includeInstance, msg) { + var f, obj = { + session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f), + chatid: jspb.Message.getFieldWithDefault(msg, 2, ""), + labelid: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.messages.ChatLabelRequest} + */ +proto.messages.ChatLabelRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.messages.ChatLabelRequest; + return proto.messages.ChatLabelRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.messages.ChatLabelRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.messages.ChatLabelRequest} + */ +proto.messages.ChatLabelRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.messages.Session; + reader.readMessage(value,proto.messages.Session.deserializeBinaryFromReader); + msg.setSession(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setChatid(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setLabelid(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.messages.ChatLabelRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.messages.ChatLabelRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.messages.ChatLabelRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.messages.ChatLabelRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSession(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.messages.Session.serializeBinaryToWriter + ); + } + f = message.getChatid(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getLabelid(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional Session session = 1; + * @return {?proto.messages.Session} + */ +proto.messages.ChatLabelRequest.prototype.getSession = function() { + return /** @type{?proto.messages.Session} */ ( + jspb.Message.getWrapperField(this, proto.messages.Session, 1)); +}; + + +/** + * @param {?proto.messages.Session|undefined} value + * @return {!proto.messages.ChatLabelRequest} returns this +*/ +proto.messages.ChatLabelRequest.prototype.setSession = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.messages.ChatLabelRequest} returns this + */ +proto.messages.ChatLabelRequest.prototype.clearSession = function() { + return this.setSession(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.messages.ChatLabelRequest.prototype.hasSession = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string chatId = 2; + * @return {string} + */ +proto.messages.ChatLabelRequest.prototype.getChatid = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.messages.ChatLabelRequest} returns this + */ +proto.messages.ChatLabelRequest.prototype.setChatid = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string labelId = 3; + * @return {string} + */ +proto.messages.ChatLabelRequest.prototype.getLabelid = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.messages.ChatLabelRequest} returns this + */ +proto.messages.ChatLabelRequest.prototype.setLabelid = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + /** * @enum {number} */ diff --git a/src/core/engines/gows/labels.gows.ts b/src/core/engines/gows/labels.gows.ts new file mode 100644 index 00000000..65bbed9b --- /dev/null +++ b/src/core/engines/gows/labels.gows.ts @@ -0,0 +1,45 @@ +import { toCusFormat } from '@waha/core/engines/noweb/session.noweb.core'; +import { Label, LabelChatAssociation } from '@waha/structures/labels.dto'; + +import * as gows from './types'; + +/** + * Converts a GOWS LabelEdit event to a Label DTO + */ +export function eventToLabelDTO(labelEdit: gows.LabelEdit): Label { + return { + id: labelEdit.LabelID, + name: labelEdit.Action.name, + color: labelEdit.Action.color, + colorHex: Label.toHex(labelEdit.Action.color), + } as Label; +} + +/** + * Converts a GOWS LabelAssociationChat event to a LabelChatAssociation DTO + */ +export function eventToLabelChatAssociationDTO( + labelAssoc: gows.LabelAssociationChat, +): LabelChatAssociation { + return { + labelId: labelAssoc.LabelID, + label: null, // We don't have the label info here + chatId: toCusFormat(labelAssoc.JID), + }; +} + +/** + * Checks if a LabelEdit event is for a label creation or update (not deletion) + */ +export function isLabelUpsertEvent(labelEdit: gows.LabelEdit): boolean { + return !labelEdit.Action.deleted; +} + +/** + * Checks if a LabelAssociationChat event is for adding a label to a chat + */ +export function isLabelChatAddedEvent( + labelAssoc: gows.LabelAssociationChat, +): boolean { + return labelAssoc.Action.labeled === true; +} diff --git a/src/core/engines/gows/session.gows.core.ts b/src/core/engines/gows/session.gows.core.ts index f773dc84..94786a62 100644 --- a/src/core/engines/gows/session.gows.core.ts +++ b/src/core/engines/gows/session.gows.core.ts @@ -133,9 +133,20 @@ import { promisify } from 'util'; import * as gows from './types'; import { MessageStatus } from './types'; import MessageServiceClient = messages.MessageServiceClient; +import { isFromFullSync } from '@waha/core/engines/gows/appstate'; import { toVcard } from '@waha/core/helpers'; import { AckToStatus } from '@waha/core/utils/acks'; import { DistinctAck } from '@waha/core/utils/reactive'; +import { Label, LabelDTO, LabelID } from '@waha/structures/labels.dto'; +import { exclude } from '@waha/utils/reactive/ops/exclude'; +import * as lodash from 'lodash'; + +import { + eventToLabelChatAssociationDTO, + eventToLabelDTO, + isLabelChatAddedEvent, + isLabelUpsertEvent, +} from './labels.gows'; enum WhatsMeowEvent { CONNECTED = 'gows.ConnectedEventData', @@ -152,6 +163,9 @@ enum WhatsMeowEvent { // Groups GROUP_INFO = 'events.GroupInfo', JOINED_GROUP = 'events.JoinedGroup', + // Labels + LABEL_EDIT = 'events.LabelEdit', + LABEL_ASSOCIATION_CHAT = 'events.LabelAssociationChat', } const gRPCClientConfig = { @@ -421,6 +435,51 @@ export class WhatsappSessionGoWSCore extends WhatsappSession { filter(Boolean), ); this.events2.get(WAHAEvents.GROUP_V2_UPDATE).switch(groupV2Update$); + + // Label Events + // First, create streams for the raw label events + const labelEditEvents$ = all$.pipe( + onlyEvent(WhatsMeowEvent.LABEL_EDIT), + exclude(isFromFullSync), + ); + + // Split the raw label edit events into upsert and deleted events + const [labelUpsertEvents$, labelDeletedEvents$] = partition( + labelEditEvents$, + isLabelUpsertEvent, + ); + + // Convert the events to DTOs + const labelUpsert$ = labelUpsertEvents$.pipe(map(eventToLabelDTO)); + + const labelDeleted$ = labelDeletedEvents$.pipe(map(eventToLabelDTO)); + + this.events2.get(WAHAEvents.LABEL_UPSERT).switch(labelUpsert$); + this.events2.get(WAHAEvents.LABEL_DELETED).switch(labelDeleted$); + + // Handle label association events + const labelAssociationEvents$ = all$.pipe( + onlyEvent(WhatsMeowEvent.LABEL_ASSOCIATION_CHAT), + exclude(isFromFullSync), + ); + + // Split the raw label association events into added and deleted events + const [labelChatAddedEvents$, labelChatDeletedEvents$] = partition( + labelAssociationEvents$, + isLabelChatAddedEvent, + ); + + // Convert the events to DTOs + const labelChatAdded$ = labelChatAddedEvents$.pipe( + map(eventToLabelChatAssociationDTO), + ); + + const labelChatDeleted$ = labelChatDeletedEvents$.pipe( + map(eventToLabelChatAssociationDTO), + ); + + this.events2.get(WAHAEvents.LABEL_CHAT_ADDED).switch(labelChatAdded$); + this.events2.get(WAHAEvents.LABEL_CHAT_DELETED).switch(labelChatDeleted$); } async fetchContactProfilePicture(id: string): Promise { @@ -1406,6 +1465,119 @@ export class WhatsappSessionGoWSCore extends WhatsappSession { return this.processIncomingMessage(msg, query.downloadMedia); } + /** + * Labels methods + */ + + public async getLabels(): Promise { + const request = new messages.GetLabelsRequest({ + session: this.session, + }); + const response = await promisify(this.client.GetLabels)(request); + const labels = parseJsonList(response); + return labels.map(this.toLabel); + } + + public async createLabel(labelDto: LabelDTO): Promise