Skip to content

Commit bf357e7

Browse files
authored
Merge pull request #8 from mconcrete/mconcrete-patch-1
Update Signal.node.ts
2 parents 2bb5c49 + 8f89c7a commit bf357e7

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

nodes/Signal/Signal.node.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,24 @@ export class Signal implements INodeType {
443443
try {
444444
let response;
445445
debug('Signal Node: Executing with resource=%s, operation=%s', resource, operation);
446-
if (resource === 'message' && operation === 'send') {
447-
const account = this.getNodeParameter('account', 0) as string;
448-
const recipient = this.getNodeParameter('recipient', 0) as string;
449-
const message = this.getNodeParameter('message', 0) as string;
446+
if (resource === "message" && operation === "send") {
447+
const account = this.getNodeParameter("account", 0) as string;
448+
const recipient = this.getNodeParameter("recipient", 0) as string;
449+
const message = this.getNodeParameter("message", 0) as string;
450+
// check if the value of recipient is a group based on if there are alphabetical characters in the string
451+
const isTargetAGroup = /[a-zA-Z]/.test(recipient);
450452

451-
const requestBody = {
452-
jsonrpc: '2.0',
453-
method: 'send',
454-
params: { account, recipient, message },
455-
id: uuidv4(),
453+
const requestBody = {
454+
jsonrpc: "2.0",
455+
method: "send",
456+
params: {
457+
account,
458+
message,
459+
//if value is group send with groupId prefix as required by Signal-cli, otherwise pass through as phone number via recipient
460+
[isTargetAGroup ? "groupId" : "recipient"]: recipient,
461+
},
462+
id: uuidv4(),
463+
456464
};
457465
debug('Signal Node: Sending message with requestBody=%o', requestBody);
458466
response = await axios.post(`${url}`, requestBody);

0 commit comments

Comments
 (0)