Merge pull request #76 from jaywink/assignee-on-created-issue

Add issue assignee to issue created message, if issue assigned on creation
This commit is contained in:
Will Hunt 2021-11-22 17:42:37 +00:00 committed by GitHub
commit d2cb53eda9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

4
.gitignore vendored
View File

@ -5,6 +5,8 @@ node_modules/
public/
registration.yml
tsconfig.tsbuildinfo
public/
.idea
# Added by cargo
/target
/target

View File

@ -141,7 +141,7 @@ export class GitHubRepoConnection implements IConnection {
],
};
}
static helpMessage: (cmdPrefix: string) => MatrixMessageContent;
static botCommands: BotCommands;
@ -286,8 +286,11 @@ export class GitHubRepoConnection implements IConnection {
throw Error('No repository content!');
}
const orgRepoName = event.repository.full_name;
const content = emoji.emojify(`${event.issue.user?.login} created new issue [${orgRepoName}#${event.issue.number}](${event.issue.html_url}): "${event.issue.title}"`);
let message = `${event.issue.user?.login} created new issue [${orgRepoName}#${event.issue.number}](${event.issue.html_url}): "${event.issue.title}"`;
message = message + (event.issue.assignee ? ` assigned to ${event.issue.assignee.login}` : '');
const content = emoji.emojify(message);
const { labelsHtml, labelsStr } = FormatUtil.formatLabels(event.issue.labels);
const labels = FormatUtil.formatLabels(event.issue.labels?.map(l => ({ name: l.name, description: l.description || undefined, color: l.color || undefined })));
await this.as.botIntent.sendEvent(this.roomId, {
msgtype: "m.notice",
@ -388,7 +391,7 @@ export class GitHubRepoConnection implements IConnection {
format: "org.matrix.custom.html",
// TODO: Fix types.
...FormatUtil.getPartialBodyForIssue(event.repository, event.pull_request as any),
});
});
}
public async onPRReviewed(event: PullRequestReviewSubmittedEvent) {
@ -539,4 +542,4 @@ ${event.release.body}`;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res = compileBotCommands(GitHubRepoConnection.prototype as any);
GitHubRepoConnection.helpMessage = res.helpMessage;
GitHubRepoConnection.botCommands = res.botCommands;
GitHubRepoConnection.botCommands = res.botCommands;