wa-js icon indicating copy to clipboard operation
wa-js copied to clipboard

For delete and revoke msg use:

Open Souhaibahar opened this issue 1 year ago • 4 comments

          For delete and revoke msg use:
await WPP.chat.deleteMessage('[number]@c.us', '[[email protected]_3EB06A9EC8E5624576163', true, true);

Originally posted by @icleitoncosta in https://github.com/wppconnect-team/wa-js/issues/2047#issuecomment-2187646198

this worked to unsend my own messages ,, but it dosen't delete the message for chat , and only works for the messages i sended and can't delete the messages i received

Souhaibahar avatar Jun 27 '24 13:06 Souhaibahar

Could you record a video reproducing the error and post it here? I tested with my messages and received messages, and both delete normally.

icleitoncosta avatar Jul 01 '24 16:07 icleitoncosta

public async Task<bool> DeleteMessage(string contactId, string messageId)
{
    try
    {
        var jsCode = $@"
        async () => {{
            try {{
                await WPP.chat.deleteMessage('{contactId}@c.us', '{messageId}', true, true);
                return {{ success: true }};
            }} catch (error) {{
                return {{ success: false, error: error.message }};
            }}
        }}";

        dynamic result = await Page.EvaluateFunctionAsync(jsCode).ConfigureAwait(false);
        if ((bool)result.success)
        {
            return true;
        }
        else
        {
            LogSvc.AddLog("CLIENT SIDE EXCEPTION: Error deleting message: " + result.error);
            return false;
        }
    }
    catch (Exception ex)
    {
        LogSvc.AddLog("SERVER SIDE EXCEPTION : Error deleting message: " + ex.Message);
        return false;
    }
}

Souhaibahar avatar Jul 04 '24 13:07 Souhaibahar

the thing is it always return True

Souhaibahar avatar Jul 04 '24 13:07 Souhaibahar

if i tried in my messages , they will be revoked but not delete , and if i tried on my received messages nothing happend , and no error from javascript or .net side

Souhaibahar avatar Jul 04 '24 13:07 Souhaibahar

Fixed by https://github.com/wppconnect-team/wa-js/commit/e8429480485c87cbdf874949ac866ed2b2e27a91

icleitoncosta avatar Jul 18 '24 22:07 icleitoncosta