Skip to content

Discord webhooks - #69

Open
CreedsCode wants to merge 5 commits into
v2from
discord-webhook
Open

Discord webhooks#69
CreedsCode wants to merge 5 commits into
v2from
discord-webhook

Conversation

@CreedsCode

Copy link
Copy Markdown

image
image

@CreedsCode
CreedsCode requested a review from 0xRomain February 20, 2024 22:53
@vercel

vercel Bot commented Feb 20, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
builder-place ❌ Failed (Inspect) Feb 25, 2024 8:46am
test-builder-place ❌ Failed (Inspect) Feb 25, 2024 8:46am

@0xRomain
0xRomain changed the base branch from main to v2 February 22, 2024 20:49
Comment thread package.json
Comment thread src/pages/api/delegate/create-update-service.ts Outdated
embeds: [embed],
};

fetch(webhookDetails?.discordWebhook, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to seperate the preparation of the content and the fetch to not duplicate the whole part here and add some more strict typing

// },
};

const payload = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need typing

Comment thread prisma/schema.prisma Outdated
cover String?
customDomain String? @unique
icon String?
discordWebhook String? @default("")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discordWebhookUrl seems more clear

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to generate your db migration

};


export const getDiscordWebhookDetailsByBuilderPlaceId = async (id: string) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for maintanability, i think it's good to not create a new get function everytime we want some info on a BP. We can use a single getById that returns all the datas

let errorMessage;
try {

if (builderPlace.discordWebhook != "" && builderPlace.discordWebhook != undefined) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 things here:

  • both conditon are falsy, so just do: if (builderPlace.discordWebhook)
  • it's better to move this check logical inside your function, else you have to duplicate it everywhere we need to use it



export const sendNewServiceNotification = async (builderPlaceId: string, serviceId: string, cid: string) => {
const service: { title: string, about: string, keywords: string, rateToken: string, rateAmount: string } = await readFromIPFS(cid);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in term of architecture, we now make any create service API post success depending on an IPFS call, and discord call. This is not good for maintability. Would be better to imagine something non bloquant with a message broker by example. Any suggestion?

},
{
name: "Budget",
value: `${(Number(service.rateAmount) / Math.pow(10, token.decimals)).toString()} ${token.symbol}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have helper normally for that

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could not find one, i tried searching the code base for "Math.pow" and nothing come up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants