Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getDevice #309

Closed
wants to merge 2 commits into from
Closed

Update getDevice #309

wants to merge 2 commits into from

Conversation

okfull
Copy link
Contributor

@okfull okfull commented Aug 5, 2023

Before getDevice returned id that had above 21 characters as 'android', but whatsapp web messages were returned as 'android' too.

An example of a WhatsApp Web message id that returned android: "id": "3EB0F513CA2F3372B995CA", containing 22 characters (above 21 = android)

Now it's fixed

@whiskeysockets-bot
Copy link
Contributor

Thanks for your contribution.

The next step is to wait for review and approval to merge it to main repository

The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it.

To test this PR you can run the following command below:

# NPM
npm install @whiskeysockets/baileys@programadorbob/Baileys#d1
# YARN v2
yarn add @whiskeysockets/baileys@programadorbob/Baileys#d1

Copy link
Contributor

@vermaysha vermaysha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@@ -733,7 +733,7 @@ export const extractMessageContent = (content: WAMessageContent | undefined | nu
* Returns the device predicted by message ID
*/
export const getDevice = (id: string) => {
const deviceType = id.length > 21 ? 'android' : id.substring(0, 2) === '3A' ? 'ios' : 'web'
const deviceType = id.substring(0, 2) === '3E' ? 'web' : id.substring(0, 2) === '3A' ? 'ios' : 'android'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think every android has an ID length of 32 and web always starts with 3EB0

@okfull okfull closed this Oct 16, 2023
@okfull okfull deleted the d1 branch October 16, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants