[core] GOWS - support mentions

fix #1372
This commit is contained in:
devlikepro committed 2025-11-07 13:55:02 +07:00
1 parent da294a58a6
commit e75912435b
3 files changed
+77 -4

No files matched your search

+24 -1
View File
@@ -3564,9 +3564,10 @@ export namespace messages {
list?: ListMessage;
location?: Location;
pollVote?: PollVoteMessage;
mentions?: string[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [11, 13], this.#one_of_decls);
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [11, 13, 19], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("session" in data && data.session != undefined) {
this.session = data.session;
@@ -3622,6 +3623,9 @@ export namespace messages {
if ("pollVote" in data && data.pollVote != undefined) {
this.pollVote = data.pollVote;
}
if ("mentions" in data && data.mentions != undefined) {
this.mentions = data.mentions;
}
}
}
get session() {
@@ -3762,6 +3766,12 @@ export namespace messages {
get has_pollVote() {
return pb_1.Message.getField(this, 18) != null;
}
get mentions() {
return pb_1.Message.getFieldWithDefault(this, 19, []) as string[];
}
set mentions(value: string[]) {
pb_1.Message.setField(this, 19, value);
}
static fromObject(data: {
session?: ReturnType<typeof Session.prototype.toObject>;
jid?: string;
@@ -3781,6 +3791,7 @@ export namespace messages {
list?: ReturnType<typeof ListMessage.prototype.toObject>;
location?: ReturnType<typeof Location.prototype.toObject>;
pollVote?: ReturnType<typeof PollVoteMessage.prototype.toObject>;
mentions?: string[];
}): MessageRequest {
const message = new MessageRequest({});
if (data.session != null) {
@@ -3837,6 +3848,9 @@ export namespace messages {
if (data.pollVote != null) {
message.pollVote = PollVoteMessage.fromObject(data.pollVote);
}
if (data.mentions != null) {
message.mentions = data.mentions;
}
return message;
}
toObject() {
@@ -3859,6 +3873,7 @@ export namespace messages {
list?: ReturnType<typeof ListMessage.prototype.toObject>;
location?: ReturnType<typeof Location.prototype.toObject>;
pollVote?: ReturnType<typeof PollVoteMessage.prototype.toObject>;
mentions?: string[];
} = {};
if (this.session != null) {
data.session = this.session.toObject();
@@ -3914,6 +3929,9 @@ export namespace messages {
if (this.pollVote != null) {
data.pollVote = this.pollVote.toObject();
}
if (this.mentions != null) {
data.mentions = this.mentions;
}
return data;
}
serialize(): Uint8Array;
@@ -3956,6 +3974,8 @@ export namespace messages {
writer.writeMessage(17, this.location, () => this.location.serialize(writer));
if (this.has_pollVote)
writer.writeMessage(18, this.pollVote, () => this.pollVote.serialize(writer));
if (this.mentions.length)
writer.writeRepeatedString(19, this.mentions);
if (!w)
return writer.getResultBuffer();
}
@@ -4019,6 +4039,9 @@ export namespace messages {
case 18:
reader.readMessage(message.pollVote, () => message.pollVote = PollVoteMessage.deserialize(reader));
break;
case 19:
pb_1.Message.addToRepeatedField(message, 19, reader.readString());
break;
default: reader.skipField();
}
}
+51 -2
View File
@@ -8555,7 +8555,7 @@ proto.messages.EventMessage.prototype.hasLocation = function() {
* @private {!Array<number>}
* @const
*/
proto.messages.MessageRequest.repeatedFields_ = [11,13];
proto.messages.MessageRequest.repeatedFields_ = [11,13,19];
@@ -8606,7 +8606,8 @@ proto.messages.MessageRequest.toObject = function(includeInstance, msg) {
poll: (f = msg.getPoll()) && proto.messages.PollMessage.toObject(includeInstance, f),
list: (f = msg.getList()) && proto.messages.ListMessage.toObject(includeInstance, f),
location: (f = msg.getLocation()) && proto.messages.Location.toObject(includeInstance, f),
pollvote: (f = msg.getPollvote()) && proto.messages.PollVoteMessage.toObject(includeInstance, f)
pollvote: (f = msg.getPollvote()) && proto.messages.PollVoteMessage.toObject(includeInstance, f),
mentionsList: (f = jspb.Message.getRepeatedField(msg, 19)) == null ? undefined : f
};
if (includeInstance) {
@@ -8726,6 +8727,10 @@ proto.messages.MessageRequest.deserializeBinaryFromReader = function(msg, reader
reader.readMessage(value,proto.messages.PollVoteMessage.deserializeBinaryFromReader);
msg.setPollvote(value);
break;
case 19:
var value = /** @type {string} */ (reader.readString());
msg.addMentions(value);
break;
default:
reader.skipField();
break;
@@ -8892,6 +8897,13 @@ proto.messages.MessageRequest.serializeBinaryToWriter = function(message, writer
proto.messages.PollVoteMessage.serializeBinaryToWriter
);
}
f = message.getMentionsList();
if (f.length > 0) {
writer.writeRepeatedString(
19,
f
);
}
};
@@ -9448,6 +9460,43 @@ proto.messages.MessageRequest.prototype.hasPollvote = function() {
};
/**
* repeated string mentions = 19;
* @return {!Array<string>}
*/
proto.messages.MessageRequest.prototype.getMentionsList = function() {
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 19));
};
/**
* @param {!Array<string>} value
* @return {!proto.messages.MessageRequest} returns this
*/
proto.messages.MessageRequest.prototype.setMentionsList = function(value) {
return jspb.Message.setField(this, 19, value || []);
};
/**
* @param {string} value
* @param {number=} opt_index
* @return {!proto.messages.MessageRequest} returns this
*/
proto.messages.MessageRequest.prototype.addMentions = function(value, opt_index) {
return jspb.Message.addToRepeatedField(this, 19, value, opt_index);
};
/**
* Clears the list making it empty but non-null.
* @return {!proto.messages.MessageRequest} returns this
*/
proto.messages.MessageRequest.prototype.clearMentionsList = function() {
return this.setMentionsList([]);
};
+2 -1
View File
@@ -804,6 +804,7 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
linkPreview: request.linkPreview ?? true,
linkPreviewHighQuality: request.linkPreviewHighQuality,
replyTo: getMessageIdFromSerialized(request.reply_to),
mentions: request.mentions?.map((mention) => toJID(mention)),
});
const response = await promisify(this.client.SendMessage)(message);
const data = response.toObject();
@@ -999,7 +1000,7 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
}
reply(request: MessageReplyRequest) {
throw new Error('Method not implemented.');
return this.sendText(request);
}
async sendSeen(request: SendSeenRequest) {