indianracingcommunity / RLIProject

IRC Website
MIT License
7 stars 2 forks source link

Create a Notification Factory class to support sending messages of various formats to Discord #199

Open kapilace6 opened 1 year ago

kapilace6 commented 1 year ago

Apart from the ActivityLog class, which logs every action (non-GET) to the DB, we would also like to send notifications of certain events to a corresponding Discord channel.

Each event would have a message format(template), a discord channel, args to fill the message. The interface (if being built) should support an option to DM a particular user on Discord.

There may be an extension of the Notification Factory to calendar / email notifications in the future. Ensure that the interface is appropriately modeled to account for other channels.

Reference: https://dev.to/akhilarjun/factory-pattern-java-design-patterns-5h33

kapilace6 commented 1 year ago

Interactions with Discord

What are the various features of RLIProject?

What are the various tables in ircproject Database?

Other use cases

kapilace6 commented 1 year ago

APIs to integrate

References

Task List

TheFreeman15 commented 1 year ago

We should also see how to maintain a channel ID mapping in our database so each module does not have to pass the discord channel ID manually and should pass a reference of that channel ID

Also if any notification is estimitated to have high volumes of calls to discord for sending message or running any events, ratelimits have to be taken into consideration as discord will have dynamic rate limit values for each API which is returned in a response header as X-RateLimit-Limit: 5

Refer: Discord Rate Limits

kapilace6 commented 1 year ago

Why is there a need for channel ID mapping? Can you provide any cons to the channel IDs being saved and retrieved from a model directly?

As for rate limits, the HTTP client we are using will take care of 429 and 5xx responses from discord, through retries. We should log every one of these errors, such that we can analyze any bottlenecks in the future.