Skip to content

Commit

Permalink
Merge branch 'main' of github.com:christophehurpeau/reviewflow into r…
Browse files Browse the repository at this point in the history
…enovate/probot-13.x
  • Loading branch information
christophehurpeau committed Apr 10, 2024
2 parents 79481d9 + a0a02be commit 459369d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let mongoConnection: MongoConnection | null = null;
const serverPromise = run((app, { getRouter }) => {
const mongoStores = mongoInit();
mongoConnection = mongoStores.connection;
const slackHome = createSlackHomeWorker(mongoStores);
const slackHome = createSlackHomeWorker(mongoStores, app.log);
const appContext: AppContext = { mongoStores, slackHome };
appRouter(app, getRouter, appContext);
initApp(app, appContext);
Expand Down
33 changes: 24 additions & 9 deletions src/slack/home.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { KnownBlock } from '@slack/web-api';
import { WebClient } from '@slack/web-api';
import type { Probot } from 'probot';
import type { MongoStores, Org, OrgMember, ReviewflowPr } from '../mongo';
import type { Octokit } from '../octokit';
import { ExcludesFalsy } from '../utils/Excludes';
Expand All @@ -17,7 +18,10 @@ interface QueueItem {
const buildPullRequestUrl = (reviewflowPullRequest: ReviewflowPr): string =>
`https://github.com/${reviewflowPullRequest.account.login}/${reviewflowPullRequest.repo.name}/pull/${reviewflowPullRequest.pr.number}`;

export const createSlackHomeWorker = (mongoStores: MongoStores) => {
export const createSlackHomeWorker = (
mongoStores: MongoStores,
log: Probot['log'],
) => {
const updateMember = async (
octokit: Octokit,
slackClient: WebClient,
Expand All @@ -40,7 +44,9 @@ export const createSlackHomeWorker = (mongoStores: MongoStores) => {
sort: 'created',
order: 'desc',
})
.catch((error: unknown) => ({ error })),
.catch((error: unknown) => {
log.error('Error searching PRs', { error });
}),
mongoStores.prs.findAll(
{
'account.id': member.org.id,
Expand Down Expand Up @@ -363,13 +369,22 @@ export const createSlackHomeWorker = (mongoStores: MongoStores) => {
});
}

slackClient.views.publish({
user_id: member.slack.id,
view: {
type: 'home',
blocks,
},
});
slackClient.views
.publish({
user_id: member.slack.id,
view: {
type: 'home',
blocks,
},
})
.catch((error) => {
log.error('Error updating home', {
error,
memberLogin: member.user.login,
orgLogin: member.org.login,
blocks,
});
});
};

let workerInterval: ReturnType<typeof setInterval> | undefined;
Expand Down
56 changes: 12 additions & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3073,26 +3073,6 @@ __metadata:
languageName: node
linkType: hard

"body-parser@npm:1.20.1":
version: 1.20.1
resolution: "body-parser@npm:1.20.1"
dependencies:
bytes: "npm:3.1.2"
content-type: "npm:~1.0.4"
debug: "npm:2.6.9"
depd: "npm:2.0.0"
destroy: "npm:1.2.0"
http-errors: "npm:2.0.0"
iconv-lite: "npm:0.4.24"
on-finished: "npm:2.4.1"
qs: "npm:6.11.0"
raw-body: "npm:2.5.1"
type-is: "npm:~1.6.18"
unpipe: "npm:1.0.0"
checksum: 10/5f8d128022a2fb8b6e7990d30878a0182f300b70e46b3f9d358a9433ad6275f0de46add6d63206da3637c01c3b38b6111a7480f7e7ac2e9f7b989f6133fe5510
languageName: node
linkType: hard

"body-parser@npm:1.20.2":
version: 1.20.2
resolution: "body-parser@npm:1.20.2"
Expand Down Expand Up @@ -3676,10 +3656,10 @@ __metadata:
languageName: node
linkType: hard

"cookie@npm:0.5.0":
version: 0.5.0
resolution: "cookie@npm:0.5.0"
checksum: 10/aae7911ddc5f444a9025fbd979ad1b5d60191011339bce48e555cb83343d0f98b865ff5c4d71fecdfb8555a5cafdc65632f6fce172f32aaf6936830a883a0380
"cookie@npm:0.6.0":
version: 0.6.0
resolution: "cookie@npm:0.6.0"
checksum: 10/c1f8f2ea7d443b9331680598b0ae4e6af18a618c37606d1bbdc75bec8361cce09fe93e727059a673f2ba24467131a9fb5a4eec76bb1b149c1b3e1ccb268dc583
languageName: node
linkType: hard

Expand Down Expand Up @@ -4665,15 +4645,15 @@ __metadata:
linkType: hard

"express@npm:^4.18.2":
version: 4.18.2
resolution: "express@npm:4.18.2"
version: 4.19.2
resolution: "express@npm:4.19.2"
dependencies:
accepts: "npm:~1.3.8"
array-flatten: "npm:1.1.1"
body-parser: "npm:1.20.1"
body-parser: "npm:1.20.2"
content-disposition: "npm:0.5.4"
content-type: "npm:~1.0.4"
cookie: "npm:0.5.0"
cookie: "npm:0.6.0"
cookie-signature: "npm:1.0.6"
debug: "npm:2.6.9"
depd: "npm:2.0.0"
Expand All @@ -4699,7 +4679,7 @@ __metadata:
type-is: "npm:~1.6.18"
utils-merge: "npm:1.0.1"
vary: "npm:~1.1.2"
checksum: 10/869ae89ed6ff4bed7b373079dc58e5dddcf2915a2669b36037ff78c99d675ae930e5fe052b35c24f56557d28a023bb1cbe3e2f2fb87eaab96a1cedd7e597809d
checksum: 10/3fcd792536f802c059789ef48db3851b87e78fba103423e524144d79af37da7952a2b8d4e1a007f423329c7377d686d9476ac42e7d9ea413b80345d495e30a3a
languageName: node
linkType: hard

Expand Down Expand Up @@ -4867,12 +4847,12 @@ __metadata:
linkType: hard

"follow-redirects@npm:^1.15.4":
version: 1.15.5
resolution: "follow-redirects@npm:1.15.5"
version: 1.15.6
resolution: "follow-redirects@npm:1.15.6"
peerDependenciesMeta:
debug:
optional: true
checksum: 10/d467f13c1c6aa734599b8b369cd7a625b20081af358f6204ff515f6f4116eb440de9c4e0c49f10798eeb0df26c95dd05d5e0d9ddc5786ab1a8a8abefe92929b4
checksum: 10/70c7612c4cab18e546e36b991bbf8009a1a41cf85354afe04b113d1117569abf760269409cb3eb842d9f7b03d62826687086b081c566ea7b1e6613cf29030bf7
languageName: node
linkType: hard

Expand Down Expand Up @@ -8459,18 +8439,6 @@ __metadata:
languageName: node
linkType: hard

"raw-body@npm:2.5.1":
version: 2.5.1
resolution: "raw-body@npm:2.5.1"
dependencies:
bytes: "npm:3.1.2"
http-errors: "npm:2.0.0"
iconv-lite: "npm:0.4.24"
unpipe: "npm:1.0.0"
checksum: 10/280bedc12db3490ecd06f740bdcf66093a07535374b51331242382c0e130bb273ebb611b7bc4cba1b4b4e016cc7b1f4b05a6df885a6af39c2bc3b94c02291c84
languageName: node
linkType: hard

"raw-body@npm:2.5.2":
version: 2.5.2
resolution: "raw-body@npm:2.5.2"
Expand Down

0 comments on commit 459369d

Please sign in to comment.