Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Feature/confluence settings (#211)
Browse files Browse the repository at this point in the history
* Make all unlogged services lose title

* Create watermelon.ts

* Use standard type

* use standard types

* Use standard types

* Create general case helper

* Make code more readable

* Allow number to be a string, like a slack channel

* Add possible body

* Standardize helpers

* Remove unused helpers

* Add possible image element

* Remove unused code

* use standard response

* remove logging, fix text

* Fix token errors in confluence

* Better responses on success and failure

* Check nulls

* Add max results

* Add limit using amount

* create StandardAPIInput

* Fix type

* Create OptionDropdown component

* Change to max 5

* Fix code

* Make it component based, add confluence

* Remove component unused

* Fix loading page
  • Loading branch information
EstebanDalelR committed Aug 2, 2023
1 parent d2c04bf commit 3d2afd4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 252 deletions.
68 changes: 41 additions & 27 deletions pages/api/actions/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@ import getNotion from "../../../utils/actions/getNotion";
import getLinear from "../../../utils/actions/getLinear";
import getOpenAISummary from "../../../utils/actions/getOpenAISummary";

import githubMarkdown from "../../../utils/actions/markdownHelpers/github";
import jiraMarkdown from "../../../utils/actions/markdownHelpers/jira";
import slackMarkdown from "../../../utils/actions/markdownHelpers/slack";
import notionMarkdown from "../../../utils/actions/markdownHelpers/notion";
import linearMarkdown from "../../../utils/actions/markdownHelpers/linear";
import countMarkdown from "../../../utils/actions/markdownHelpers/count";
import generalMarkdownHelper from "../../../utils/actions/markdownHelpers/helper";

import addActionLog from "../../../utils/db/github/addActionLog";
import getConfluence from "../../../utils/actions/getConfluence";
import confluenceMarkdown from "../../../utils/actions/markdownHelpers/confluence";
const app = new App({
appId: process.env.GITHUB_APP_ID!,
privateKey: process.env.GITHUB_PRIVATE_KEY!,
});

export default async (req, res) => {
if (req.method === "POST") {
let textToWrite = "";
try {
// Verify and parse the webhook event
const eventName = req.headers["x-github-event"];
Expand Down Expand Up @@ -368,7 +364,6 @@ export default async (req, res) => {
}),
addActionCount({ watermelon_user }),
]);
let textToWrite = "";
textToWrite += `### WatermelonAI Summary (BETA) \n`;

let businessLogicSummary;
Expand All @@ -392,35 +387,47 @@ export default async (req, res) => {
textToWrite += `AI Summary deactivated by ${userLogin} \n`;
}

textToWrite += githubMarkdown({
GitHubPRs,
ghValue,
textToWrite += generalMarkdownHelper({
amount: GitHubPRs,
value: ghValue,
userLogin,
systemName: "GitHub",
systemResponseName: "GitHub PRs",
});
textToWrite += jiraMarkdown({
JiraTickets,
jiraValue,
textToWrite += generalMarkdownHelper({
amount: JiraTickets,
value: jiraValue,
userLogin,
systemName: "Jira",
systemResponseName: "Jira Tickets",
});
textToWrite += confluenceMarkdown({
ConfluenceDocs: 3,
confluenceValue,
textToWrite += generalMarkdownHelper({
amount: 3,
value: confluenceValue,
userLogin,
systemName: "Confluence",
systemResponseName: "Confluence Docs",
});
textToWrite += slackMarkdown({
SlackMessages,
slackValue,
textToWrite += generalMarkdownHelper({
amount: SlackMessages,
value: slackValue,
userLogin,
systemName: "Slack",
systemResponseName: "Slack Threads",
});
textToWrite += notionMarkdown({
NotionPages,
notionValue,
textToWrite += generalMarkdownHelper({
amount: NotionPages,
value: notionValue,
userLogin,
systemName: "Notion",
systemResponseName: "Notion Pages",
});
textToWrite += linearMarkdown({
LinearTickets,
linearValue,
textToWrite += generalMarkdownHelper({
amount: LinearTickets,
value: linearValue,
userLogin,
systemName: "Linear",
systemResponseName: "Linear Tickets",
});
textToWrite += countMarkdown({
count,
Expand Down Expand Up @@ -496,10 +503,17 @@ export default async (req, res) => {
});
}
}
return res.status(200).send("Webhook event processed");
return res.status(200).json({
message: "success",
textToWrite,
});
} catch (error) {
console.error("general action processing error", error);
res.status(500).send("Error processing webhook event");
res.status(500).json({
message: "Error processing webhook event",
error,
textToWrite,
});
}
} else {
res.setHeader("Allow", "POST");
Expand Down
1 change: 0 additions & 1 deletion utils/actions/getSlack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { StandardAPIResponse } from "../../types/watermelon";
import searchMessageByText from "../../utils/slack/searchMessageByText";
type SlackResult = { error: string } | any[];
async function getSlack({
title,
body,
Expand Down
42 changes: 0 additions & 42 deletions utils/actions/markdownHelpers/confluence.ts

This file was deleted.

31 changes: 0 additions & 31 deletions utils/actions/markdownHelpers/github.ts

This file was deleted.

36 changes: 0 additions & 36 deletions utils/actions/markdownHelpers/jira.ts

This file was deleted.

35 changes: 0 additions & 35 deletions utils/actions/markdownHelpers/linear.ts

This file was deleted.

42 changes: 0 additions & 42 deletions utils/actions/markdownHelpers/notion.ts

This file was deleted.

38 changes: 0 additions & 38 deletions utils/actions/markdownHelpers/slack.ts

This file was deleted.

0 comments on commit 3d2afd4

Please sign in to comment.