hoehermann / purple-gowhatsapp

Pidgin/libpurple plugin for WhatsApp Web.
GNU General Public License v3.0
276 stars 34 forks source link

Feature Request: Implement viewing edited messages #199

Closed Juliaria08 closed 1 month ago

Juliaria08 commented 1 month ago

If possible, make a edited message send a new message (maybe if some configuration option is enabled)

I was also thinking of editing messages but I think my idea is over-engineered. (The idea in question is, with each message, at the end or at the beginning (if some option is enabled), put the message's id, maybe in square brackets to differentiate it from the message, and then make a ?editmessage <messageid> <message>, that sends the proper editmessage message),

And for viewing edited messages, it should put something like "(edited)" at the end. Because you can't tell libpurple to change the message, right?

Fell free to split the other issue into two, I'm not sure if I should do that.

hoehermann commented 1 month ago

Hi @Juliaria08

Thank you for the request. I have not looked into how editing messages is handled in WhatsApp and cannot tell how feasible it is. I hope I can tend to it one day. As always, contributions are welcome. Until then, I want to keep this issue as a reminder.

Kind Regards Hermann

Juliaria08 commented 1 month ago

Oh, ok. No problem.

Juliaria08 commented 1 month ago

It seems to create a message without text, because I see Received a message without any text run, so maybe there needs to be special treatment if isEdit is true.

This is what the logs shown me, I've snipped the user id's, and modified the message ID:

[Client/Recv] <message edit="1" from="[snip]@s.whatsapp.net" id="53F045XXXXXXXXXXXXXXXXXXB49984DE" notify="[snip]" sender_lid="[snip]@lid" t="1716028651" type="text"><enc decrypt-fail="hide" type="pkmsg" v="2"><!-- 295 bytes --></enc></message>
[Client] Decrypting message from [snip]@s.whatsapp.net
[Client/Send] <ack class="message" id="53F045XXXXXXXXXXXXXXXXXXB49984DE" to="[snip]@s.whatsapp.net"/>
[Handler] Received a message without any text.
[Client/Send] <receipt id="53F045XXXXXXXXXXXXXXXXXXB49984DE" to="[snip]@s.whatsapp.net"/>

I have not looked into how editing messages is handled in WhatsApp and cannot tell how feasible it is

I think you might misunderstood this, this issue was made to view edited messages, not to edit, but I ranted on the description too much so I might've made it hard to notice that it is just to view edited messages, and I suggest about a possibility on how to edit messages, by using BuildEdit, BuildEdit docs in pkg.go.dev I think I should make another issue for editing messages but I'm unsure, if so, please tell me and I'll do.

hoehermann commented 1 month ago

Thank you for your input. With the information you provided, it was easier. Previously, I had been looking into the EditedMessage field. However, that was always nil. The edited message can actually be found in ProtocolMessage. Does 5904f78 work for you?

Juliaria08 commented 1 month ago

Thank you for your input. With the information you provided, it was easier. Previously, I had been looking into the EditedMessage field. However, that was always nil. The edited message can actually be found in ProtocolMessage. Does 5904f78 work for you?

Yes it does. Thanks.

Juliaria08 commented 1 month ago

@hoehermann But I'd probably recommend making the code not log message in Line 22

hoehermann commented 1 month ago

Whoops. I forgot to re-add the comment. Thank you for pointing out the mistake. Fixed in current whatsmeow branch.