Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : Added the feature of sending the notification of latest video/note to discord #601

Closed

Conversation

amanbairagi30
Copy link
Contributor

Problem Statement

Currently, whenever a new video is uploaded into the CMS, Harkirat has to update the Discord community about it. This process requires additional effort after posting the video in the CMS.

Solution

I have implemented a solution where whenever a new video or note is added from the CMS admin panel, a notification for that video or note can be seen in Discord. I have made this an optional choice. If moderators want to add a video/note without sending a notification to discord, they can do so. Additionally , I have provided a checkbox for this purpose . Along with that in discord message you can even go to that particular video /note location by clicking the link provided there .

You can see the changes below :

2024-04-28.16-11-19.mp4

Checklist before requesting a review

  • I have performed a self-review of my code
  • I assure there is no similar/duplicate pull request regarding same issue

@amanbairagi30
Copy link
Contributor Author

Hey @hkirat , I have made the necessary changes you asked in live stream , and creating a new PR as the old one has some weird merge conflicts . I would request you to review this PR .

@siinghd
Copy link
Collaborator

siinghd commented Jun 14, 2024

@amanbairagi30

can you add instruction and update .env.example on what do we need to setup the discord webhook url?

Also solve the conflicts

@amanbairagi30 amanbairagi30 force-pushed the feat/discord-notification branch from fdb6d4a to 499d178 Compare June 14, 2024 04:46
@amanbairagi30
Copy link
Contributor Author

@amanbairagi30

can you add instruction and update .env.example on what do we need to setup the discord webhook url?

Also solve the conflicts

Done ⚡

Copy link
Collaborator

@siinghd siinghd left a comment

Choose a reason for hiding this comment

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

Please review the changes the requested and also can you add that if there is no webhook in the .env do not execute the request


try {
const res = await axios.post(
`${process.env.NEXT_PUBLIC_DISCORD_WEBHOOK_URL}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is being leaked on client site please move this login on server side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done ser ✌


const respData: { id: number } = await response.json();

const data = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is unnecessary here, do it server side here at /api/admin/content

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so @siinghd , do you want me to shift all of this logic to api/admin/content route and send checked variable in this request ?

const response = await fetch('/api/admin/content', {
      body: JSON.stringify({
        type,
        description: '',
        thumbnail: imageUri,
        title,
        courseId,
        parentContentId,
        metadata,
        adminPassword,
      }),
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
    });```

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes sir, also if no webhook env is set, do not send the dicord request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay ser , understood . 🙌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done ser ✌

@amanbairagi30 amanbairagi30 requested a review from siinghd June 16, 2024 18:19
@amanbairagi30
Copy link
Contributor Author

@siinghd , you may check now .

@amanbairagi30
Copy link
Contributor Author

@siinghd sir ji , please look into this .

@amanbairagi30
Copy link
Contributor Author

@siinghd ?

@amanbairagi30
Copy link
Contributor Author

closing it as it has been merged to main via another PR

@amanbairagi30 amanbairagi30 deleted the feat/discord-notification branch September 27, 2024 17:22
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