Skip to content

Commit

Permalink
[core] linkPreview: false|true
Browse files Browse the repository at this point in the history
  • Loading branch information
devlikepro committed Nov 6, 2024
1 parent 65942a4 commit eb218da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/engines/noweb/session.noweb.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
const message = {
text: request.text,
mentions: request.mentions?.map(toJID),
linkPreview: this.getLinkPreview(request),
};
const options = await this.getMessageOptions(request);
return this.sock.sendMessage(chatId, message, options);
Expand Down Expand Up @@ -1686,6 +1687,22 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
quoted: quoted,
};
}

protected getLinkPreview(request): any {
// NOWEB works this way
// If it's undefined - it'll generate it
// If it's false - it will not generate it
let linkPreview: boolean | undefined;
switch (request.linkPreview) {
case false:
linkPreview = false;
break;
case true:
default:
linkPreview = undefined;
}
return linkPreview;
}
}

function hasPath(url: string) {
Expand Down
1 change: 1 addition & 0 deletions src/core/engines/webjs/session.webjs.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
return {
mentions: mentions,
quotedMessageId: quotedMessageId,
linkPreview: request.linkPreview,
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/structures/chatting.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export class MessageTextRequest extends ChatRequest {

@ReplyToProperty()
reply_to?: string;

linkPreview?: boolean = true;
}

export class EditMessageRequest {
Expand Down

0 comments on commit eb218da

Please sign in to comment.