Skip to content

Commit

Permalink
chore: add logging for chat creation decisions
Browse files Browse the repository at this point in the history
Added log messages for reasons to skip chat.
  • Loading branch information
gentlementlegen committed Oct 13, 2024
1 parent 77a12d5 commit 8f95312
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/bot/mtproto-api/workrooms/create-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve
const chatName = "@" + payload.repository.full_name + "#" + payload.issue.number;

if (chatName.includes("devpool-directory")) {
logger.info("Skipping chat creation (reason: devpool-directory is ignored).");
return { status: 200, reason: "skipped" };
}

const labelName = payload.label?.name.toLowerCase();

if (!labelName?.toLowerCase().includes("price")) {
logger.info("Skipping chat creation (reason: no price label has been set).");
return { status: 200, reason: "skipped" };
}

logger.info("Will attempt to create a new chat room...", { labelName });
const mtProto = new MtProto(context);
await mtProto.initialize();
let chatId: number;
Expand Down Expand Up @@ -57,7 +60,14 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve

if ("link" in inviteLink) {
link = inviteLink.link;
await addCommentToIssue(context, `A new workroom has been created for this task. [Join chat](${link})`, owner, repo, payload.issue.number);

await addCommentToIssue(
context,
logger.ok(`A new workroom has been created for this task. [Join chat](${link})`).logMessage.raw,
owner,
repo,
payload.issue.number
);
} else {
throw new Error(logger.error(`Failed to create chat invite link for the workroom: ${chatName}`).logMessage.raw);
}
Expand Down

0 comments on commit 8f95312

Please sign in to comment.