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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Socket/messages-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ export const makeMessagesSocket = (config: SocketConfig) => {
if(!participant) {
devices.push({ user })
// do not send message to self if the device is 0 (mobile)
if (meDevice != undefined && meDevice !== 0) devices.push({ user: meUser })
if(meDevice !== undefined && meDevice !== 0) {
devices.push({ user: meUser })
}

const additionalDevices = await getUSyncDevices([ meId, jid ], !!useUserDevicesCache, true)
devices.push(...additionalDevices)
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

return deviceType
}

Expand Down