mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 13:17:08 +00:00
Add support for mentioning multiple assignees on GitHub issues (#889)
* Add support for multiple assignees on issues * changelog
This commit is contained in:
parent
ee7e3ff03f
commit
90927a71f4
1
changelog.d/889.feature
Normal file
1
changelog.d/889.feature
Normal file
@ -0,0 +1 @@
|
||||
Mention all assignees when a new issue is created on GitHub.
|
@ -887,7 +887,7 @@ export class GitHubRepoConnection extends CommandConnection<GitHubRepoConnection
|
||||
|
||||
const icon = '📥';
|
||||
let message = emojify(`${icon} **${event.issue.user.login}** created new issue [${orgRepoName}#${event.issue.number}](${event.issue.html_url}): "${event.issue.title}"`);
|
||||
message += (event.issue.assignee ? ` assigned to ${event.issue.assignee.login}` : '');
|
||||
message += (event.issue.assignees.length ? ` assigned to ${event.issue.assignees.map(a => a.login).join(', ')}` : '');
|
||||
if (this.showIssueRoomLink) {
|
||||
const appInstance = await this.githubInstance.getSafeOctokitForRepo(this.org, this.repo);
|
||||
if (appInstance) {
|
||||
|
@ -6,6 +6,7 @@ import { DefaultConfig } from "../../src/config/Defaults";
|
||||
import { AppserviceMock } from "../utils/AppserviceMock";
|
||||
import { ApiError, ErrCode, ValidatorApiError } from "../../src/api";
|
||||
import { expect } from "chai";
|
||||
import { IntentMock } from "../utils/IntentMock";
|
||||
|
||||
const ROOM_ID = "!foo:bar";
|
||||
|
||||
@ -58,7 +59,7 @@ function createConnection(state: Record<string, unknown> = {}, isExistingState=f
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
DefaultConfig.github!
|
||||
);
|
||||
return {connection, intent};
|
||||
return {connection, intent: intent as IntentMock};
|
||||
}
|
||||
|
||||
describe("GitHubRepoConnection", () => {
|
||||
@ -136,6 +137,21 @@ describe("GitHubRepoConnection", () => {
|
||||
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.html_url, 0);
|
||||
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.title, 0);
|
||||
});
|
||||
it.only("will handle assignees on issue creation", async () => {
|
||||
const { connection, intent } = createConnection();
|
||||
await connection.onIssueCreated({
|
||||
...GITHUB_ISSUE_CREATED_PAYLOAD,
|
||||
issue: {
|
||||
...GITHUB_ISSUE,
|
||||
assignees: [{ login: 'alice'}, { login: 'bob'}]
|
||||
}
|
||||
} as never);
|
||||
// Statement text.
|
||||
intent.expectEventBodyContains('**alice** created new issue', 0);
|
||||
intent.expectEventBodyContains('"My issue" assigned to alice, bob', 0);
|
||||
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.html_url, 0);
|
||||
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.title, 0);
|
||||
});
|
||||
it("will filter out issues not matching includingLabels.", async () => {
|
||||
const { connection, intent } = createConnection({
|
||||
includingLabels: ["include-me"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user