style: oxfmt format
This commit is contained in:
@@ -20,13 +20,20 @@ describe("resolveConversationLabel", () => {
|
||||
});
|
||||
|
||||
it("does not append ids for #rooms/channels", () => {
|
||||
const ctx: MsgContext = { ChatType: "channel", GroupSubject: "#general", From: "slack:channel:C123" };
|
||||
const ctx: MsgContext = {
|
||||
ChatType: "channel",
|
||||
GroupSubject: "#general",
|
||||
From: "slack:channel:C123",
|
||||
};
|
||||
expect(resolveConversationLabel(ctx)).toBe("#general");
|
||||
});
|
||||
|
||||
it("appends ids for WhatsApp-like group ids when a subject exists", () => {
|
||||
const ctx: MsgContext = { ChatType: "group", GroupSubject: "Family", From: "whatsapp:group:123@g.us" };
|
||||
const ctx: MsgContext = {
|
||||
ChatType: "group",
|
||||
GroupSubject: "Family",
|
||||
From: "whatsapp:group:123@g.us",
|
||||
};
|
||||
expect(resolveConversationLabel(ctx)).toBe("Family id:123@g.us");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -43,4 +43,3 @@ export function resolveConversationLabel(ctx: MsgContext): string | undefined {
|
||||
if (base.startsWith("#") || base.startsWith("@")) return base;
|
||||
return `${base} id:${id}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,7 @@ export const whatsappOutbound: ChannelOutboundAdapter = {
|
||||
}
|
||||
return {
|
||||
ok: false,
|
||||
error: missingTargetError(
|
||||
"WhatsApp",
|
||||
"<E.164|group JID> or channels.whatsapp.allowFrom[0]",
|
||||
),
|
||||
error: missingTargetError("WhatsApp", "<E.164|group JID> or channels.whatsapp.allowFrom[0]"),
|
||||
};
|
||||
},
|
||||
sendText: async ({ to, text, accountId, deps, gifPlayback }) => {
|
||||
|
||||
@@ -202,10 +202,7 @@ export const signalPlugin: ChannelPlugin<ResolvedSignalAccount> = {
|
||||
if (!trimmed) {
|
||||
return {
|
||||
ok: false,
|
||||
error: missingTargetError(
|
||||
"Signal",
|
||||
"<E.164|group:ID|signal:group:ID|signal:+E.164>",
|
||||
),
|
||||
error: missingTargetError("Signal", "<E.164|group:ID|signal:group:ID|signal:+E.164>"),
|
||||
};
|
||||
}
|
||||
return { ok: true, to: trimmed };
|
||||
|
||||
@@ -342,7 +342,10 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
|
||||
}
|
||||
return {
|
||||
ok: false,
|
||||
error: missingTargetError("WhatsApp", "<E.164|group JID> or channels.whatsapp.allowFrom[0]"),
|
||||
error: missingTargetError(
|
||||
"WhatsApp",
|
||||
"<E.164|group JID> or channels.whatsapp.allowFrom[0]",
|
||||
),
|
||||
};
|
||||
},
|
||||
sendText: async ({ to, text, accountId, deps, gifPlayback }) => {
|
||||
|
||||
@@ -11,7 +11,9 @@ describe("validateSenderIdentity", () => {
|
||||
|
||||
it("requires some sender identity for non-direct chats", () => {
|
||||
const ctx: MsgContext = { ChatType: "group" };
|
||||
expect(validateSenderIdentity(ctx)).toContain("missing sender identity (SenderId/SenderName/SenderUsername/SenderE164)");
|
||||
expect(validateSenderIdentity(ctx)).toContain(
|
||||
"missing sender identity (SenderId/SenderName/SenderUsername/SenderE164)",
|
||||
);
|
||||
});
|
||||
|
||||
it("validates SenderE164 and SenderUsername shape", () => {
|
||||
@@ -27,4 +29,3 @@ describe("validateSenderIdentity", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ export function validateSenderIdentity(ctx: MsgContext): string[] {
|
||||
}
|
||||
|
||||
if (senderUsername) {
|
||||
if (senderUsername.includes("@")) issues.push(`SenderUsername should not include "@": ${senderUsername}`);
|
||||
if (/\s/.test(senderUsername)) issues.push(`SenderUsername should not include whitespace: ${senderUsername}`);
|
||||
if (senderUsername.includes("@"))
|
||||
issues.push(`SenderUsername should not include "@": ${senderUsername}`);
|
||||
if (/\s/.test(senderUsername))
|
||||
issues.push(`SenderUsername should not include whitespace: ${senderUsername}`);
|
||||
}
|
||||
|
||||
if (ctx.SenderId != null && !senderId) {
|
||||
@@ -35,4 +37,3 @@ export function validateSenderIdentity(ctx: MsgContext): string[] {
|
||||
|
||||
return issues;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user