-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
770 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface IPRdetail{ | ||
title: string; | ||
number:string; | ||
url: string; | ||
id: string; | ||
createdAt: Date; | ||
ageInDays?:number; | ||
author: { avatar: string; username: string; };repo:string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface IReminder { | ||
userid:string, | ||
username:string, | ||
repos: string[]; | ||
unsubscribedPR:{repo:string,prnum:number[]}[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export enum ProcessorsEnum { | ||
REMOVE_GITHUB_LOGIN = 'remove_github_token', | ||
REMOVE_GITHUB_LOGIN = 'remove_github_token', | ||
PR_REMINDER = 'pr_reminder', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { IHttp, IModify, IPersistence, IRead } 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 { IUser } from "@rocket.chat/apps-engine/definition/users"; | ||
import { GithubApp } from "../GithubApp"; | ||
import { HandleInvalidRepoName } from "./HandleInvalidRepoName"; | ||
import { CreateReminder } from "../persistance/remind"; | ||
import { sendNotification } from "../lib/message"; | ||
|
||
export async function createReminder( | ||
repository: string, | ||
room: IRoom, | ||
read: IRead, | ||
app: GithubApp, | ||
persistence: IPersistence, | ||
modify: IModify, | ||
http: IHttp, | ||
user: IUser | ||
) { | ||
|
||
const repoName = repository; | ||
|
||
const isValidRepo = await HandleInvalidRepoName( | ||
repoName, | ||
http, | ||
app, | ||
modify, | ||
user, | ||
read, | ||
room | ||
) | ||
|
||
if (!isValidRepo) { | ||
return; | ||
} else { | ||
await CreateReminder(read, persistence, user, repoName); | ||
} | ||
|
||
await sendNotification(read, modify, user, room, `Pull Request Reminder Set for [${repoName}](https://github.com/${repoName}) 👍`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
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 { GithubApp } from "../GithubApp"; | ||
import { sendNotification } from "../lib/message"; | ||
import { NewIssueStarterModal } from "../modals/newIssueStarterModal"; | ||
import { getAccessTokenForUser } from "../persistance/auth"; | ||
import { GitHubIssuesStarterModal } from "../modals/getIssuesStarterModal"; | ||
import { NewReminderStarterModal } from "../modals/newreminderModal"; | ||
import { reminderModal } from "../modals/remindersModal"; | ||
|
||
export async function handleReminder( | ||
read: IRead, | ||
context: SlashCommandContext, | ||
app: GithubApp, | ||
persistence: IPersistence, | ||
http: IHttp, | ||
room: IRoom, | ||
modify: IModify | ||
){ | ||
let accessToken = await getAccessTokenForUser( | ||
read, | ||
context.getSender(), | ||
app.oauth2Config | ||
); | ||
if (accessToken && accessToken.token) { | ||
const triggerId = context.getTriggerId(); | ||
if (triggerId) { | ||
const modal = await NewReminderStarterModal({ | ||
modify: modify, | ||
read: read, | ||
persistence: persistence, | ||
http: http, | ||
slashcommandcontext: context, | ||
}); | ||
await modify | ||
.getUiController() | ||
.openModalView( | ||
modal, | ||
{ triggerId }, | ||
context.getSender() | ||
); | ||
} else { | ||
console.log("invalid Trigger ID !"); | ||
} | ||
} else { | ||
await sendNotification( | ||
read, | ||
modify, | ||
context.getSender(), | ||
room, | ||
"Login to add Pull Request reminder! `/github login`" | ||
); | ||
} | ||
} | ||
|
||
export async function ManageReminders( | ||
read:IRead, | ||
context:SlashCommandContext, | ||
app:GithubApp, | ||
persistence:IPersistence, | ||
http:IHttp, | ||
room:IRoom, | ||
modify:IModify | ||
){ | ||
let accessToken = await getAccessTokenForUser( | ||
read, | ||
context.getSender(), | ||
app.oauth2Config | ||
); | ||
if (accessToken && accessToken.token) { | ||
const triggerId = context.getTriggerId(); | ||
if (triggerId) { | ||
const modal = await reminderModal({ | ||
modify: modify, | ||
read: read, | ||
persistence: persistence, | ||
http: http, | ||
slashcommandcontext: context, | ||
}); | ||
await modify | ||
.getUiController() | ||
.openModalView(modal, { triggerId }, context.getSender()); | ||
} else { | ||
console.log("Invalid Trigger ID !"); | ||
} | ||
} else { | ||
await sendNotification( | ||
read, | ||
modify, | ||
context.getSender(), | ||
room, | ||
"Login to see to pull request reminders! `/github login`" | ||
); | ||
} | ||
} |
Oops, something went wrong.