-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathUserProfileHandler.ts
More file actions
54 lines (53 loc) · 1.66 KB
/
UserProfileHandler.ts
File metadata and controls
54 lines (53 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {
IRead,
IPersistence,
IHttp,
IModify,
} from "@rocket.chat/apps-engine/definition/accessors";
import { IRoom } from "@rocket.chat/apps-engine/definition/rooms";
import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands";
import { UIKitInteractionContext } from "@rocket.chat/apps-engine/definition/uikit";
import { GithubApp } from "../GithubApp";
import { sendNotification } from "../lib/message";
import { userProfileModal } from "../modals/UserProfileModal";
import { getAccessTokenForUser } from "../persistance/auth";
export async function handleUserProfileRequest(
read: IRead,
context: SlashCommandContext,
app: GithubApp,
persistence: IPersistence,
http: IHttp,
room: IRoom,
modify: IModify,
uikitcontext?: UIKitInteractionContext
) {
let access_token = await getAccessTokenForUser(
read,
context.getSender(),
app.oauth2Config
);
if (access_token?.token) {
const triggerId = context.getTriggerId();
if (triggerId) {
const modal = await userProfileModal({
app: app,
modify: modify,
read: read,
persistence: persistence,
http: http,
slashcommandcontext: context,
});
await modify
.getUiController()
.openModalView(modal, { triggerId }, context.getSender());
}
} else {
await sendNotification(
read,
modify,
context.getSender(),
room,
"Login is Mandatory for getting User Info ! `/github login`"
);
}
}