This commit is contained in:
Adhiraj Singh
2022-03-29 12:12:22 +05:30
5 changed files with 24 additions and 5 deletions

View File

@@ -749,6 +749,13 @@ Of course, replace ``` xyz ``` with an actual ID.
```
Of course, replace ``` xxx ``` with invitation code.
- To join the group using groupInviteMessage
``` ts
const response = await sock.groupAcceptInviteV4(groupInviteMessage)
console.log("joined to: " + response)
```
Of course, replace ``` xxx ``` with invitation code.
## Broadcast Lists & Stories
**Note:** messages cannot be sent to broadcast lists from the MD version right now

View File

@@ -421,6 +421,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
type = 'available'
}
if (firstChild.attrs?.media === 'audio'){
type = 'recording';
}
presence = { lastKnownPresence: type }
} else {
logger.error({ tag, attrs, content }, 'recv invalid presence node')

View File

@@ -2,6 +2,7 @@ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types'
import { generateMessageID } from '../Utils'
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode, jidNormalizedUser } from '../WABinary'
import { makeSocket } from './socket'
import { proto } from '../../WAProto'
export const makeGroupsSocket = (config: SocketConfig) => {
const sock = makeSocket(config)
@@ -134,6 +135,13 @@ export const makeGroupsSocket = (config: SocketConfig) => {
const result = getBinaryNodeChild(results, 'group')
return result.attrs.jid
},
groupAcceptInviteV4: async(jid: string, inviteMessage: proto.IGroupInviteMessage) => {
const results = await groupQuery(inviteMessage.groupJid, 'set', [{ tag: 'accept', attrs: {
code: inviteMessage.inviteCode,
expiration: inviteMessage.inviteExpiration.toString(),
admin: jid} }])
return results.attrs.from;
},
groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => {
const content: BinaryNode = ephemeralExpiration ?
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :

View File

@@ -239,7 +239,7 @@ export default (
const fromJSON = (json: { chats: Chat[], contacts: { [id: string]: Contact }, messages: { [id: string]: WAMessage[] } }) => {
chats.upsert(...json.chats)
contactsUpsert(Object.values(contacts))
contactsUpsert(Object.values(json.contacts))
for(const jid in json.messages) {
const list = assertMessageList(jid)
for(const msg of json.messages[jid]) {

View File

@@ -81,7 +81,7 @@ const extractVideoThumb = async(
time: string,
size: { width: number; height: number },
) => new Promise((resolve, reject) => {
const cmd = `ffmpeg -ss ${time} -i ${path} -y -s ${size.width}x${size.height} -vframes 1 -f image2 ${destPath}`
const cmd = `ffmpeg -ss ${time} -i ${path} -y -vf scale=${size.width}:-1 -vframes 1 -f image2 ${destPath}`
exec(cmd, (err) => {
if(err) {
reject(err)
@@ -99,17 +99,17 @@ export const extractImageThumb = async(bufferOrFilePath: Readable | Buffer | str
const lib = await getImageProcessingLibrary()
if('sharp' in lib) {
const result = await lib.sharp!.default(bufferOrFilePath)
.resize(32, 32)
.resize(32)
.jpeg({ quality: 50 })
.toBuffer()
return result
} else {
const { read, MIME_JPEG, RESIZE_BILINEAR } = lib.jimp
const { read, MIME_JPEG, RESIZE_BILINEAR, AUTO } = lib.jimp
const jimp = await read(bufferOrFilePath as any)
const result = await jimp
.quality(50)
.resize(32, 32, RESIZE_BILINEAR)
.resize(32, AUTO, RESIZE_BILINEAR)
.getBufferAsync(MIME_JPEG)
return result
}