Skip to content

Commit

Permalink
Merge pull request #6 from amanbairagi30/add-feilds
Browse files Browse the repository at this point in the history
feat : Added the PR and date fields in notion
  • Loading branch information
hkirat authored May 11, 2024
2 parents 68c8ae5 + 91382ef commit 5b4be86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const webhookHandler = factory.createHandlers(
const username = body.sender.login;
const message = body.comment.body;
const author = body.issue.user.login;
const pr_link = body.issue.html_url;
const createdAt = body.comment.created_at.split("T")[0]

if (
!isBountyComment(message) ||
Expand All @@ -68,6 +70,8 @@ export const webhookHandler = factory.createHandlers(
await addBountyToNotion({
username: author,
amount: bountyAmount,
pr: pr_link,
date: createdAt,
notion: {
apiKey: notionApiKey,
databaseId: notionDatabaseId,
Expand Down
16 changes: 16 additions & 0 deletions src/notion/notion.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Client } from '@notionhq/client';
type CreatePageArgs = {
username: string;
amount: string;
pr: string;
date: string;
notion: {
apiKey: string;
databaseId: string;
Expand All @@ -11,6 +13,8 @@ type CreatePageArgs = {
export async function addBountyToNotion({
username,
amount,
pr,
date,
notion: { apiKey, databaseId },
}: CreatePageArgs) {
const notion = new Client({
Expand Down Expand Up @@ -38,6 +42,18 @@ export async function addBountyToNotion({
},
],
},
PR: {
url: pr
},
Date: {
rich_text: [
{
text: {
content: date,
},
},
],
},
Claimed: {
checkbox: false,
},
Expand Down

0 comments on commit 5b4be86

Please sign in to comment.