Compare commits

..
6 Commits
Author SHA1 Message Date
devlikepro 443f09d5a2 [core] 2025.2.3
Release / WEBJS - chrome - amd64 - chrome (push) Waiting to run
Release / WEBJS - chromium - amd64 - latest (push) Waiting to run
Release / WEBJS - chromium - linux/arm64 - arm (push) Waiting to run
Release / GOWS - none - amd64 - gows (push) Waiting to run
Release / GOWS - none - linux/arm64 - gows-arm (push) Waiting to run
Release / NOWEB - none - amd64 - noweb (push) Waiting to run
Release / NOWEB - none - linux/arm64 - noweb-arm (push) Waiting to run
2025-02-12 17:18:00 +07:00
devlikepro 3500952bb7 [core] Up GOWS 2025-02-12 17:18:00 +07:00
devlikepro e98182c4b5 [core] Add /profile API
fix #529
2025-02-12 17:18:00 +07:00
devlikepro 2337827744 [core] GOWS hasMedia fix 2025-02-12 17:18:00 +07:00
devlikepro 556dd66af3 [core] NOWEB hasMedia fix 2025-02-12 17:18:00 +07:00
devlikepro 8bdad3f4f9 [core] WEBJS hasMedia fix 2025-02-12 17:17:59 +07:00
17 changed files with 1331 additions and 24 deletions

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
import {
Body,
Controller,
Delete,
Get,
Put,
UnprocessableEntityException,
UsePipes,
} from '@nestjs/common';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { SessionManager } from '@waha/core/abc/manager.abc';
import { WhatsappSession } from '@waha/core/abc/session.abc';
import {
SessionApiParam,
WorkingSessionParam,
} from '@waha/nestjs/params/SessionApiParam';
import { WAHAValidationPipe } from '@waha/nestjs/pipes/WAHAValidationPipe';
import { Result } from '@waha/structures/base.dto';
import {
MyProfile,
ProfileNameRequest,
ProfilePictureRequest,
ProfileStatusRequest,
} from '@waha/structures/profile.dto';
@ApiSecurity('api_key')
@Controller('api/:session/profile')
@ApiTags('🆔 Profile')
export class ProfileController {
constructor(private manager: SessionManager) {}
@Get('')
@SessionApiParam
@ApiOperation({ summary: 'Get my profile' })
async getMyProfile(
@WorkingSessionParam session: WhatsappSession,
): Promise<MyProfile> {
const me = session.getSessionMeInfo();
if (!me) {
throw new UnprocessableEntityException('No profile found');
}
const picture = await session.getContactProfilePicture(me.id, false);
return {
id: me.id,
name: me.pushName,
picture: picture || null,
};
}
@Put('/name')
@SessionApiParam
@UsePipes(new WAHAValidationPipe())
@ApiOperation({ summary: 'Set my profile name' })
async setProfileName(
@WorkingSessionParam session: WhatsappSession,
@Body() request: ProfileNameRequest,
): Promise<Result> {
const success = await session.setProfileName(request.name);
return { success: success ?? true };
}
@Put('/status')
@SessionApiParam
@UsePipes(new WAHAValidationPipe())
@ApiOperation({ summary: 'Set profile status (About)' })
async setProfileStatus(
@WorkingSessionParam session: WhatsappSession,
@Body() request: ProfileStatusRequest,
): Promise<Result> {
const success = await session.setProfileStatus(request.status);
return { success: success ?? true };
}
@Put('/picture')
@SessionApiParam
@ApiOperation({ summary: 'Set profile picture' })
async setProfilePicture(
@WorkingSessionParam session: WhatsappSession,
@Body() request: ProfilePictureRequest,
): Promise<Result> {
const success = await session.updateProfilePicture(request.file);
return { success: success ?? true };
}
@Delete('/picture')
@SessionApiParam
@ApiOperation({ summary: 'Delete profile picture' })
async deleteProfilePicture(
@WorkingSessionParam session: WhatsappSession,
): Promise<Result> {
const success = await session.updateProfilePicture(null);
return { success: success || true };
}
}
+1
View File
@@ -57,6 +57,7 @@ export class SwaggerConfiguratorCore {
.setVersion(VERSION.version)
.addTag('🖥️ Sessions', 'Control WhatsApp sessions (accounts)')
.addTag('🔑 Auth', 'Authentication')
.addTag('🆔 Profile', 'Your profile information')
.addTag('🖼️ Screenshot', 'Get screenshot of WhatsApp and show QR code')
.addTag('📤 Chatting', 'Chatting methods')
.addTag('📢 Channels', 'Channels (newsletters) methods')
+51 -1
View File
@@ -15,6 +15,7 @@ import {
GetChatMessagesQuery,
} from '@waha/structures/chats.dto';
import { SendButtonsRequest } from '@waha/structures/chatting.buttons.dto';
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
import { Label, LabelDTO, LabelID } from '@waha/structures/labels.dto';
import { PaginationParams } from '@waha/structures/pagination.dto';
import { WAMessage } from '@waha/structures/responses.dto';
@@ -337,6 +338,55 @@ export abstract class WhatsappSession {
return null;
}
/**
* Profile methods
*/
public setProfileName(name: string): Promise<boolean> {
throw new NotImplementedByEngineError();
}
public setProfileStatus(status: string): Promise<boolean> {
throw new NotImplementedByEngineError();
}
public async updateProfilePicture(
file: BinaryFile | RemoteFile | null,
): Promise<boolean> {
if (file) {
await this.setProfilePicture(file);
} else {
await this.deleteProfilePicture();
}
// Refresh profile picture after update
setTimeout(() => {
this.logger.info('Refreshing my profile picture after update...');
this.refreshMyProfilePicture()
.then(() => {
this.logger.info('Refreshed my profile picture after update');
})
.catch((err) => {
this.logger.error('Error refreshing my profile picture after update');
this.logger.error(err, err.stack);
});
}, 3_000);
return true;
}
protected async refreshMyProfilePicture() {
const me = this.getSessionMeInfo();
await this.getContactProfilePicture(me.id, true);
}
protected setProfilePicture(file: BinaryFile | RemoteFile): Promise<boolean> {
throw new NotImplementedByEngineError();
}
protected deleteProfilePicture(): Promise<boolean> {
throw new NotImplementedByEngineError();
}
/**
* Other methods
*/
@@ -508,7 +558,7 @@ export abstract class WhatsappSession {
throw new NotImplementedByEngineError();
}
public getContactAbout(query: ContactQuery) {
public getContactAbout(query: ContactQuery): Promise<{ about: string }> {
throw new NotImplementedByEngineError();
}
+2
View File
@@ -5,6 +5,7 @@ import { PassportModule } from '@nestjs/passport';
import { ServeStaticModule } from '@nestjs/serve-static';
import { TerminusModule } from '@nestjs/terminus';
import { ChannelsController } from '@waha/api/channels.controller';
import { ProfileController } from '@waha/api/profile.controller';
import {
ServerController,
ServerDebugController,
@@ -121,6 +122,7 @@ const IMPORTS = [...IMPORTS_CORE, ...IMPORTS_MEDIA];
export const CONTROLLERS = [
AuthController,
SessionsController,
ProfileController,
ChattingController,
ChatsController,
ChannelsController,
+318
View File
@@ -1209,6 +1209,285 @@ export namespace messages {
return Session.deserialize(bytes);
}
}
export class ProfileNameRequest extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
session?: Session;
name?: 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 ("name" in data && data.name != undefined) {
this.name = data.name;
}
}
}
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 name() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
session?: ReturnType<typeof Session.prototype.toObject>;
name?: string;
}): ProfileNameRequest {
const message = new ProfileNameRequest({});
if (data.session != null) {
message.session = Session.fromObject(data.session);
}
if (data.name != null) {
message.name = data.name;
}
return message;
}
toObject() {
const data: {
session?: ReturnType<typeof Session.prototype.toObject>;
name?: string;
} = {};
if (this.session != null) {
data.session = this.session.toObject();
}
if (this.name != null) {
data.name = this.name;
}
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.name.length)
writer.writeString(2, this.name);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ProfileNameRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ProfileNameRequest();
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.name = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): ProfileNameRequest {
return ProfileNameRequest.deserialize(bytes);
}
}
export class ProfileStatusRequest extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
session?: Session;
status?: 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 ("status" in data && data.status != undefined) {
this.status = data.status;
}
}
}
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 status() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set status(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
session?: ReturnType<typeof Session.prototype.toObject>;
status?: string;
}): ProfileStatusRequest {
const message = new ProfileStatusRequest({});
if (data.session != null) {
message.session = Session.fromObject(data.session);
}
if (data.status != null) {
message.status = data.status;
}
return message;
}
toObject() {
const data: {
session?: ReturnType<typeof Session.prototype.toObject>;
status?: string;
} = {};
if (this.session != null) {
data.session = this.session.toObject();
}
if (this.status != null) {
data.status = this.status;
}
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.status.length)
writer.writeString(2, this.status);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ProfileStatusRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ProfileStatusRequest();
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.status = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): ProfileStatusRequest {
return ProfileStatusRequest.deserialize(bytes);
}
}
export class SetProfilePictureRequest extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
session?: Session;
picture?: Uint8Array;
}) {
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 ("picture" in data && data.picture != undefined) {
this.picture = data.picture;
}
}
}
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 picture() {
return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array;
}
set picture(value: Uint8Array) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
session?: ReturnType<typeof Session.prototype.toObject>;
picture?: Uint8Array;
}): SetProfilePictureRequest {
const message = new SetProfilePictureRequest({});
if (data.session != null) {
message.session = Session.fromObject(data.session);
}
if (data.picture != null) {
message.picture = data.picture;
}
return message;
}
toObject() {
const data: {
session?: ReturnType<typeof Session.prototype.toObject>;
picture?: Uint8Array;
} = {};
if (this.session != null) {
data.session = this.session.toObject();
}
if (this.picture != null) {
data.picture = this.picture;
}
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.picture.length)
writer.writeBytes(2, this.picture);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SetProfilePictureRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SetProfilePictureRequest();
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.picture = reader.readBytes();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SetProfilePictureRequest {
return SetProfilePictureRequest.deserialize(bytes);
}
}
export class AudioInfo extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
@@ -5559,6 +5838,33 @@ export namespace messages {
responseSerialize: (message: Empty) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes))
},
SetProfileName: {
path: "/messages.MessageService/SetProfileName",
requestStream: false,
responseStream: false,
requestSerialize: (message: ProfileNameRequest) => Buffer.from(message.serialize()),
requestDeserialize: (bytes: Buffer) => ProfileNameRequest.deserialize(new Uint8Array(bytes)),
responseSerialize: (message: Empty) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes))
},
SetProfileStatus: {
path: "/messages.MessageService/SetProfileStatus",
requestStream: false,
responseStream: false,
requestSerialize: (message: ProfileStatusRequest) => Buffer.from(message.serialize()),
requestDeserialize: (bytes: Buffer) => ProfileStatusRequest.deserialize(new Uint8Array(bytes)),
responseSerialize: (message: Empty) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes))
},
SetProfilePicture: {
path: "/messages.MessageService/SetProfilePicture",
requestStream: false,
responseStream: false,
requestSerialize: (message: SetProfilePictureRequest) => Buffer.from(message.serialize()),
requestDeserialize: (bytes: Buffer) => SetProfilePictureRequest.deserialize(new Uint8Array(bytes)),
responseSerialize: (message: Empty) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes))
},
SendMessage: {
path: "/messages.MessageService/SendMessage",
requestStream: false,
@@ -5764,6 +6070,9 @@ export namespace messages {
abstract GetSessionState(call: grpc_1.ServerUnaryCall<Session, SessionStateResponse>, callback: grpc_1.sendUnaryData<SessionStateResponse>): void;
abstract RequestCode(call: grpc_1.ServerUnaryCall<PairCodeRequest, PairCodeResponse>, callback: grpc_1.sendUnaryData<PairCodeResponse>): void;
abstract Logout(call: grpc_1.ServerUnaryCall<Session, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
abstract SetProfileName(call: grpc_1.ServerUnaryCall<ProfileNameRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
abstract SetProfileStatus(call: grpc_1.ServerUnaryCall<ProfileStatusRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
abstract SetProfilePicture(call: grpc_1.ServerUnaryCall<SetProfilePictureRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
abstract SendMessage(call: grpc_1.ServerUnaryCall<MessageRequest, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
abstract SendReaction(call: grpc_1.ServerUnaryCall<MessageReaction, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
abstract GetProfilePicture(call: grpc_1.ServerUnaryCall<ProfilePictureRequest, ProfilePictureResponse>, callback: grpc_1.sendUnaryData<ProfilePictureResponse>): void;
@@ -5806,6 +6115,15 @@ export namespace messages {
Logout: GrpcUnaryServiceInterface<Session, Empty> = (message: Session, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Empty>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Empty>, callback?: grpc_1.requestCallback<Empty>): grpc_1.ClientUnaryCall => {
return super.Logout(message, metadata, options, callback);
};
SetProfileName: GrpcUnaryServiceInterface<ProfileNameRequest, Empty> = (message: ProfileNameRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Empty>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Empty>, callback?: grpc_1.requestCallback<Empty>): grpc_1.ClientUnaryCall => {
return super.SetProfileName(message, metadata, options, callback);
};
SetProfileStatus: GrpcUnaryServiceInterface<ProfileStatusRequest, Empty> = (message: ProfileStatusRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Empty>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Empty>, callback?: grpc_1.requestCallback<Empty>): grpc_1.ClientUnaryCall => {
return super.SetProfileStatus(message, metadata, options, callback);
};
SetProfilePicture: GrpcUnaryServiceInterface<SetProfilePictureRequest, Empty> = (message: SetProfilePictureRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Empty>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Empty>, callback?: grpc_1.requestCallback<Empty>): grpc_1.ClientUnaryCall => {
return super.SetProfilePicture(message, metadata, options, callback);
};
SendMessage: GrpcUnaryServiceInterface<MessageRequest, MessageResponse> = (message: MessageRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
return super.SendMessage(message, metadata, options, callback);
};
@@ -323,6 +323,17 @@ function deserialize_messages_PresenceRequest(buffer_arg) {
return gows_pb.PresenceRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_messages_ProfileNameRequest(arg) {
if (!(arg instanceof gows_pb.ProfileNameRequest)) {
throw new Error('Expected argument of type messages.ProfileNameRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_messages_ProfileNameRequest(buffer_arg) {
return gows_pb.ProfileNameRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_messages_ProfilePictureRequest(arg) {
if (!(arg instanceof gows_pb.ProfilePictureRequest)) {
throw new Error('Expected argument of type messages.ProfilePictureRequest');
@@ -345,6 +356,17 @@ function deserialize_messages_ProfilePictureResponse(buffer_arg) {
return gows_pb.ProfilePictureResponse.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_messages_ProfileStatusRequest(arg) {
if (!(arg instanceof gows_pb.ProfileStatusRequest)) {
throw new Error('Expected argument of type messages.ProfileStatusRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_messages_ProfileStatusRequest(buffer_arg) {
return gows_pb.ProfileStatusRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_messages_SearchNewslettersByTextRequest(arg) {
if (!(arg instanceof gows_pb.SearchNewslettersByTextRequest)) {
throw new Error('Expected argument of type messages.SearchNewslettersByTextRequest');
@@ -389,6 +411,17 @@ function deserialize_messages_SessionStateResponse(buffer_arg) {
return gows_pb.SessionStateResponse.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_messages_SetProfilePictureRequest(arg) {
if (!(arg instanceof gows_pb.SetProfilePictureRequest)) {
throw new Error('Expected argument of type messages.SetProfilePictureRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_messages_SetProfilePictureRequest(buffer_arg) {
return gows_pb.SetProfilePictureRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_messages_StartSessionRequest(arg) {
if (!(arg instanceof gows_pb.StartSessionRequest)) {
throw new Error('Expected argument of type messages.StartSessionRequest');
@@ -490,6 +523,42 @@ startSession: {
responseDeserialize: deserialize_messages_Empty,
},
//
// Profile
//
setProfileName: {
path: '/messages.MessageService/SetProfileName',
requestStream: false,
responseStream: false,
requestType: gows_pb.ProfileNameRequest,
responseType: gows_pb.Empty,
requestSerialize: serialize_messages_ProfileNameRequest,
requestDeserialize: deserialize_messages_ProfileNameRequest,
responseSerialize: serialize_messages_Empty,
responseDeserialize: deserialize_messages_Empty,
},
setProfileStatus: {
path: '/messages.MessageService/SetProfileStatus',
requestStream: false,
responseStream: false,
requestType: gows_pb.ProfileStatusRequest,
responseType: gows_pb.Empty,
requestSerialize: serialize_messages_ProfileStatusRequest,
requestDeserialize: deserialize_messages_ProfileStatusRequest,
responseSerialize: serialize_messages_Empty,
responseDeserialize: deserialize_messages_Empty,
},
setProfilePicture: {
path: '/messages.MessageService/SetProfilePicture',
requestStream: false,
responseStream: false,
requestType: gows_pb.SetProfilePictureRequest,
responseType: gows_pb.Empty,
requestSerialize: serialize_messages_SetProfilePictureRequest,
requestDeserialize: deserialize_messages_SetProfilePictureRequest,
responseSerialize: serialize_messages_Empty,
responseDeserialize: deserialize_messages_Empty,
},
//
// Actions
//
sendMessage: {
+633
View File
@@ -63,8 +63,10 @@ goog.exportSymbol('proto.messages.PairCodeResponse', null, global);
goog.exportSymbol('proto.messages.PhoneInfo', null, global);
goog.exportSymbol('proto.messages.Presence', null, global);
goog.exportSymbol('proto.messages.PresenceRequest', null, global);
goog.exportSymbol('proto.messages.ProfileNameRequest', null, global);
goog.exportSymbol('proto.messages.ProfilePictureRequest', null, global);
goog.exportSymbol('proto.messages.ProfilePictureResponse', null, global);
goog.exportSymbol('proto.messages.ProfileStatusRequest', null, global);
goog.exportSymbol('proto.messages.ReceiptType', null, global);
goog.exportSymbol('proto.messages.SearchNewslettersByTextRequest', null, global);
goog.exportSymbol('proto.messages.SearchNewslettersByViewRequest', null, global);
@@ -76,6 +78,7 @@ goog.exportSymbol('proto.messages.SessionLogConfig', null, global);
goog.exportSymbol('proto.messages.SessionProxyConfig', null, global);
goog.exportSymbol('proto.messages.SessionStateResponse', null, global);
goog.exportSymbol('proto.messages.SessionStoreConfig', null, global);
goog.exportSymbol('proto.messages.SetProfilePictureRequest', null, global);
goog.exportSymbol('proto.messages.SortBy', null, global);
goog.exportSymbol('proto.messages.SortBy.Order', null, global);
goog.exportSymbol('proto.messages.StartSessionRequest', null, global);
@@ -395,6 +398,69 @@ if (goog.DEBUG && !COMPILED) {
*/
proto.messages.Session.displayName = 'proto.messages.Session';
}
/**
* 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.ProfileNameRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.messages.ProfileNameRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.messages.ProfileNameRequest.displayName = 'proto.messages.ProfileNameRequest';
}
/**
* 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.ProfileStatusRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.messages.ProfileStatusRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.messages.ProfileStatusRequest.displayName = 'proto.messages.ProfileStatusRequest';
}
/**
* 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.SetProfilePictureRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.messages.SetProfilePictureRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.messages.SetProfilePictureRequest.displayName = 'proto.messages.SetProfilePictureRequest';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
@@ -3462,6 +3528,573 @@ proto.messages.Session.prototype.setId = function(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_<name>, 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.ProfileNameRequest.prototype.toObject = function(opt_includeInstance) {
return proto.messages.ProfileNameRequest.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.ProfileNameRequest} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.messages.ProfileNameRequest.toObject = function(includeInstance, msg) {
var f, obj = {
session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f),
name: 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.messages.ProfileNameRequest}
*/
proto.messages.ProfileNameRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.messages.ProfileNameRequest;
return proto.messages.ProfileNameRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.messages.ProfileNameRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.messages.ProfileNameRequest}
*/
proto.messages.ProfileNameRequest.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.setName(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.messages.ProfileNameRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.messages.ProfileNameRequest.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.ProfileNameRequest} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.messages.ProfileNameRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getSession();
if (f != null) {
writer.writeMessage(
1,
f,
proto.messages.Session.serializeBinaryToWriter
);
}
f = message.getName();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
};
/**
* optional Session session = 1;
* @return {?proto.messages.Session}
*/
proto.messages.ProfileNameRequest.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.ProfileNameRequest} returns this
*/
proto.messages.ProfileNameRequest.prototype.setSession = function(value) {
return jspb.Message.setWrapperField(this, 1, value);
};
/**
* Clears the message field making it undefined.
* @return {!proto.messages.ProfileNameRequest} returns this
*/
proto.messages.ProfileNameRequest.prototype.clearSession = function() {
return this.setSession(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.messages.ProfileNameRequest.prototype.hasSession = function() {
return jspb.Message.getField(this, 1) != null;
};
/**
* optional string name = 2;
* @return {string}
*/
proto.messages.ProfileNameRequest.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/**
* @param {string} value
* @return {!proto.messages.ProfileNameRequest} returns this
*/
proto.messages.ProfileNameRequest.prototype.setName = 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_<name>, 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.ProfileStatusRequest.prototype.toObject = function(opt_includeInstance) {
return proto.messages.ProfileStatusRequest.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.ProfileStatusRequest} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.messages.ProfileStatusRequest.toObject = function(includeInstance, msg) {
var f, obj = {
session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f),
status: 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.messages.ProfileStatusRequest}
*/
proto.messages.ProfileStatusRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.messages.ProfileStatusRequest;
return proto.messages.ProfileStatusRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.messages.ProfileStatusRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.messages.ProfileStatusRequest}
*/
proto.messages.ProfileStatusRequest.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.setStatus(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.messages.ProfileStatusRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.messages.ProfileStatusRequest.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.ProfileStatusRequest} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.messages.ProfileStatusRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getSession();
if (f != null) {
writer.writeMessage(
1,
f,
proto.messages.Session.serializeBinaryToWriter
);
}
f = message.getStatus();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
};
/**
* optional Session session = 1;
* @return {?proto.messages.Session}
*/
proto.messages.ProfileStatusRequest.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.ProfileStatusRequest} returns this
*/
proto.messages.ProfileStatusRequest.prototype.setSession = function(value) {
return jspb.Message.setWrapperField(this, 1, value);
};
/**
* Clears the message field making it undefined.
* @return {!proto.messages.ProfileStatusRequest} returns this
*/
proto.messages.ProfileStatusRequest.prototype.clearSession = function() {
return this.setSession(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.messages.ProfileStatusRequest.prototype.hasSession = function() {
return jspb.Message.getField(this, 1) != null;
};
/**
* optional string status = 2;
* @return {string}
*/
proto.messages.ProfileStatusRequest.prototype.getStatus = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/**
* @param {string} value
* @return {!proto.messages.ProfileStatusRequest} returns this
*/
proto.messages.ProfileStatusRequest.prototype.setStatus = 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_<name>, 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.SetProfilePictureRequest.prototype.toObject = function(opt_includeInstance) {
return proto.messages.SetProfilePictureRequest.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.SetProfilePictureRequest} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.messages.SetProfilePictureRequest.toObject = function(includeInstance, msg) {
var f, obj = {
session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f),
picture: msg.getPicture_asB64()
};
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.SetProfilePictureRequest}
*/
proto.messages.SetProfilePictureRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.messages.SetProfilePictureRequest;
return proto.messages.SetProfilePictureRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.messages.SetProfilePictureRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.messages.SetProfilePictureRequest}
*/
proto.messages.SetProfilePictureRequest.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 {!Uint8Array} */ (reader.readBytes());
msg.setPicture(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.messages.SetProfilePictureRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.messages.SetProfilePictureRequest.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.SetProfilePictureRequest} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.messages.SetProfilePictureRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getSession();
if (f != null) {
writer.writeMessage(
1,
f,
proto.messages.Session.serializeBinaryToWriter
);
}
f = message.getPicture_asU8();
if (f.length > 0) {
writer.writeBytes(
2,
f
);
}
};
/**
* optional Session session = 1;
* @return {?proto.messages.Session}
*/
proto.messages.SetProfilePictureRequest.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.SetProfilePictureRequest} returns this
*/
proto.messages.SetProfilePictureRequest.prototype.setSession = function(value) {
return jspb.Message.setWrapperField(this, 1, value);
};
/**
* Clears the message field making it undefined.
* @return {!proto.messages.SetProfilePictureRequest} returns this
*/
proto.messages.SetProfilePictureRequest.prototype.clearSession = function() {
return this.setSession(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.messages.SetProfilePictureRequest.prototype.hasSession = function() {
return jspb.Message.getField(this, 1) != null;
};
/**
* optional bytes picture = 2;
* @return {!(string|Uint8Array)}
*/
proto.messages.SetProfilePictureRequest.prototype.getPicture = function() {
return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/**
* optional bytes picture = 2;
* This is a type-conversion wrapper around `getPicture()`
* @return {string}
*/
proto.messages.SetProfilePictureRequest.prototype.getPicture_asB64 = function() {
return /** @type {string} */ (jspb.Message.bytesAsB64(
this.getPicture()));
};
/**
* optional bytes picture = 2;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getPicture()`
* @return {!Uint8Array}
*/
proto.messages.SetProfilePictureRequest.prototype.getPicture_asU8 = function() {
return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(
this.getPicture()));
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.messages.SetProfilePictureRequest} returns this
*/
proto.messages.SetProfilePictureRequest.prototype.setPicture = function(value) {
return jspb.Message.setProto3BytesField(this, 2, value);
};
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
+39 -12
View File
@@ -92,6 +92,7 @@ import {
parseJsonList,
statusToAck,
} from '@waha/core/engines/gows/helpers';
import { extractMediaContent } from '@waha/core/engines/noweb/utils';
import {
ChatSortField,
ChatSummary,
@@ -100,6 +101,7 @@ import {
GetChatMessagesQuery,
} from '@waha/structures/chats.dto';
import { ContactQuery } from '@waha/structures/contacts.dto';
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
import { PaginationParams, SortOrder } from '@waha/structures/pagination.dto';
enum WhatsMeowEvent {
@@ -443,6 +445,40 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
}
}
/**
* Profile methods
*/
public async setProfileName(name: string): Promise<boolean> {
const request = new messages.ProfileNameRequest({
session: this.session,
name: name,
});
const response = await promisify(this.client.SetProfileName)(request);
response.toObject();
return true;
}
public async setProfileStatus(status: string): Promise<boolean> {
const request = new messages.ProfileStatusRequest({
session: this.session,
status: status,
});
const response = await promisify(this.client.SetProfileStatus)(request);
response.toObject();
return true;
}
protected setProfilePicture(file: BinaryFile | RemoteFile): Promise<boolean> {
throw new AvailableInPlusVersion();
}
protected deleteProfilePicture(): Promise<boolean> {
throw new AvailableInPlusVersion();
}
/**
* Other methods
*/
async sendText(request: MessageTextRequest) {
const jid = toJID(this.ensureSuffix(request.chatId));
const message = new messages.MessageRequest({
@@ -1048,6 +1084,7 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
} else {
ack = message.Info.IsFromMe ? WAMessageAck.SERVER : WAMessageAck.DEVICE;
}
const mediaContent = extractMediaContent(message.Message);
return {
id: id,
@@ -1058,8 +1095,8 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
to: toCusFormat(fromToParticipant.to),
participant: toCusFormat(fromToParticipant.participant),
// Media
hasMedia: Boolean(message.media),
media: message.media,
hasMedia: Boolean(mediaContent),
media: message.media || null,
mediaUrl: message.media?.url,
// @ts-ignore
ack: ack,
@@ -1244,16 +1281,6 @@ export class GOWSEngineMediaProcessor implements IMediaEngineProcessor<any> {
}
}
export function extractMediaContent(message: any) {
const mediaContent =
message?.documentMessage ||
message?.imageMessage ||
message?.videoMessage ||
message?.audioMessage ||
message?.stickerMessage;
return mediaContent;
}
function isMine(message) {
return !!message.Info.IsFromMe;
}
+24 -6
View File
@@ -648,6 +648,27 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
}
}
/**
* Profile methods
*/
public async setProfileName(name: string): Promise<boolean> {
await this.sock.updateProfileName(name);
return true;
}
public async setProfileStatus(status: string): Promise<boolean> {
await this.sock.updateProfileStatus(status);
return true;
}
protected setProfilePicture(file: BinaryFile | RemoteFile): Promise<boolean> {
throw new AvailableInPlusVersion();
}
protected deleteProfilePicture(): Promise<boolean> {
throw new AvailableInPlusVersion();
}
/**
* Other methods
*/
@@ -1110,10 +1131,6 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
return contacts.map(this.toWAContact);
}
public async getContactAbout(query: ContactQuery) {
throw new NotImplementedByEngineError();
}
public async fetchContactProfilePicture(id: string) {
const contact = this.ensureSuffix(id);
if (isJidNewsletter(id)) {
@@ -1696,6 +1713,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
const body = this.extractBody(message.message);
const replyTo = this.extractReplyTo(message.message);
const ack = message.ack || message.status - 1;
const mediaContent = extractMediaContent(message.message);
return Promise.resolve({
id: id,
timestamp: ensureNumber(message.messageTimestamp),
@@ -1705,8 +1723,8 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
to: toCusFormat(fromToParticipant.to),
participant: toCusFormat(fromToParticipant.participant),
// Media
hasMedia: Boolean(message.media),
media: message.media,
hasMedia: Boolean(mediaContent),
media: message.media || null,
mediaUrl: message.media?.url,
// @ts-ignore
ack: ack,
+1 -1
View File
@@ -1,7 +1,7 @@
import { extractMessageContent, proto } from '@adiwajshing/baileys';
export function extractMediaContent(
content: proto.IMessage | null | undefined,
content: any | proto.IMessage | null | undefined,
) {
content = extractMessageContent(content);
const mediaContent =
+11
View File
@@ -33,6 +33,17 @@ export class WebjsClientCore extends Client {
await this.pupPage.evaluate(LoadWAHA);
}
async setPushName(name: string) {
await this.pupPage.evaluate(async (pushName) => {
return await window['WAHA'].WAWebSetPushnameConnAction.setPushname(
pushName,
);
}, name);
if (this.info) {
this.info.pushname = name;
}
}
async unpair() {
await this.pupPage.evaluate(async () => {
if (
+10
View File
@@ -11,4 +11,14 @@ exports.LoadWAHA = () => {
const chatPromises = chats.map((chat) => window.WWebJS.getChatModel(chat));
return await Promise.all(chatPromises);
};
// Set push name
window.WAHA.WAWebSetPushnameConnAction = window.require(
'WAWebSetPushnameConnAction',
);
// Get my status
window.WAHA.WAWebTextStatusCollection = window.require(
'WAWebTextStatusCollection',
);
};
+27 -2
View File
@@ -57,6 +57,7 @@ import {
WAHASessionStatus,
WAMessageAck,
} from '@waha/structures/enums.dto';
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
import {
CreateGroupRequest,
GroupSortField,
@@ -455,6 +456,30 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
};
}
/**
* Profile methods
*/
public async setProfileName(name: string): Promise<boolean> {
await this.whatsapp.setPushName(name);
return true;
}
public async setProfileStatus(status: string): Promise<boolean> {
await this.whatsapp.setStatus(status);
return true;
}
protected setProfilePicture(file: BinaryFile | RemoteFile): Promise<boolean> {
throw new AvailableInPlusVersion();
}
protected deleteProfilePicture(): Promise<boolean> {
throw new AvailableInPlusVersion();
}
/**
* Other methods
*/
sendText(request: MessageTextRequest) {
const options = this.getMessageOptions(request);
return this.whatsapp.sendMessage(
@@ -1297,9 +1322,9 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
body: message.body,
// Media
// @ts-ignore
hasMedia: Boolean(message.media),
hasMedia: Boolean(message.hasMedia),
// @ts-ignore
media: message.media,
media: message.media || null,
// @ts-ignore
mediaUrl: message.media?.url,
// @ts-ignore
+4
View File
@@ -18,3 +18,7 @@ export class SessionQuery {
export class SessionBaseRequest {
session: string = WHATSAPP_DEFAULT_SESSION_NAME;
}
export class Result {
success: boolean = true;
}
+45
View File
@@ -0,0 +1,45 @@
import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger';
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
import { ChatIdProperty } from '@waha/structures/properties.dto';
import { IsNotEmpty, IsString } from 'class-validator';
export class MyProfile {
@ChatIdProperty()
id: string;
name: string;
@ApiProperty({
example: 'https://example.com/picture.jpg',
})
picture: string | null;
}
export class ProfileNameRequest {
@IsString()
@IsNotEmpty()
@ApiProperty({
example: 'My New Name',
})
name: string;
}
export class ProfileStatusRequest {
@IsString()
@IsNotEmpty()
@ApiProperty({
example: '🎉 Hey there! I am using WhatsApp 🎉',
})
status: string;
}
@ApiExtraModels(RemoteFile, BinaryFile)
export class ProfilePictureRequest {
@ApiProperty({
oneOf: [
{ $ref: getSchemaPath(RemoteFile) },
{ $ref: getSchemaPath(BinaryFile) },
],
})
file: BinaryFile | RemoteFile;
}
+1 -1
View File
@@ -33,7 +33,7 @@ export function getEngineName(): string {
}
export const VERSION: WAHAEnvironment = {
version: '2025.2.2',
version: '2025.2.3',
engine: getEngineName(),
tier: getWAHAVersion(),
browser: getBrowserExecutablePath(),
+1 -1
View File
@@ -2,7 +2,7 @@
"waha": {
"gows": {
"repo": "devlikeapro/gows",
"ref": "b4d8005bac5d4e9094af5fa4945a4731a656330f"
"ref": "8b31d6b88166e0962ca47a3dfbd256a42f09dbc1"
},
"dashboard": {
"repo": "devlikeapro/dashboard",