diff --git a/package.json b/package.json index 26966e5..6dc1ebb 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,10 @@ "repository": { "url": "git@github.com:adiwajshing/baileys.git" }, + "files": [ + "./lib", + "./WAMessage" + ], "dependencies": { "@adiwajshing/keyed-db": "^0.1.2", "curve25519-js": "^0.0.4", diff --git a/src/Tests/Tests.Misc.ts b/src/Tests/Tests.Misc.ts index bb1b00a..b2a5e9a 100644 --- a/src/Tests/Tests.Misc.ts +++ b/src/Tests/Tests.Misc.ts @@ -1,5 +1,5 @@ import { Presence, ChatModification, delay } from '../WAConnection/WAConnection' -import {promises as fs} from 'fs' +import { promises as fs } from 'fs' import * as assert from 'assert' import fetch from 'node-fetch' import { WAConnectionTest, testJid } from './Common' @@ -134,4 +134,11 @@ WAConnectionTest('Misc', (conn) => { await delay(1500) } }) + it('should generate link previews correctly', async () => { + await conn.generateLinkPreview ('hello this is from https://www.github.com/adiwajshing/Baileys') + // two links should fail + await assert.rejects ( + conn.generateLinkPreview ('I sent links to https://teachyourselfcs.com/ and https://www.fast.ai/') + ) + }) }) \ No newline at end of file diff --git a/src/WAConnection/0.Base.ts b/src/WAConnection/0.Base.ts index 7714b88..e400dc7 100644 --- a/src/WAConnection/0.Base.ts +++ b/src/WAConnection/0.Base.ts @@ -218,7 +218,7 @@ export class WAConnection extends EventEmitter { const response = await this.query ({json, binaryTags, tag, timeoutMs, expect200, waitForOpen}) return response } - throw new BaileysError(`Unexpected status code in '${json[0] || 'generic query'}': ${response.status}`, {query: json}) + throw new BaileysError(`Unexpected status code in '${json[0] || 'generic query'}': ${response.status}`, {query: json, status: response.status}) } return response } diff --git a/src/WAConnection/Constants.ts b/src/WAConnection/Constants.ts index 09213d4..b57b391 100644 --- a/src/WAConnection/Constants.ts +++ b/src/WAConnection/Constants.ts @@ -201,6 +201,9 @@ export enum WAMetric { queryLabel = 36, queryQuickReply = 39 } + +export const STORIES_JID = 'status@broadcast' + export enum WAFlag { ignore = 1 << 7, acknowledge = 1 << 6,