The-NeXT-Project / NeXT-Panel

Next generation proxy service management system (OSS Edition)
https://nextpanel.dev
GNU General Public License v3.0
167 stars 39 forks source link

feat: telegram notification on user purchase and ticket #27

Closed pplulee closed 6 months ago

pplulee commented 6 months ago

Fixes attempts to send messages when adding detection rules, even if Telegram notifications are not enabled.

Add notification when order is activated(Anankke/SSPanel-UIM#2394) Notify admins when the ticket is created(Anankke/SSPanel-UIM#2393), the reply function may require additional data to be stored.

Also during testing, line breaks could not be escaped well. It is stored directly in the database, but line breaks cannot be displayed in the admin settings, so when the setting is saved, it becomes a space.

AutisticShark commented 6 months ago

Oh boy, that's a lot of added lines just for config alone. Here are things I did/will do:

  1. I have moved your branch to this repo because I don't want to do a force push on other ppl's personal repo.
  2. I will create an array config to store all the notification text and reuse text configs across different types of bots.
  3. I will change most of the telegram bot config's name to avoid variable name conflict with other bot implementations.

Database config's array type actually is using json string under the hood because there is no native array type in the MariaDB, but consider this should be low-frequency data to read so that shouldn't be putting too much pressure on the PHP or database, unlike invoice type that will be checked at every cron cycle.

AutisticShark commented 6 months ago

Another thing you have to consider when adding a feature like this is the blocking nature of FPM runtime, I added a new IP login and new IP subscribe notification a while back, but those features will cause a few hundred ms of additional network delay, so they are still WiP until I can find some better solution for this blocking issue, same for those planned(I personally also wanted but then the site responsiveness become the blocker) but not yet figure out a way to do features.

I hate to say it but we may need to split most of NeXT-Panel's blocking component into several microservices, ideally written in Go for easy maintenance. Or, we add long-live runtime like RoadRunner, redo the cron system, and make the NeXT-Panel completely event-driven. Both will be breaking changes and make it extremely hard to deploy, but without those changes, this project will be at the end of the road when it comes to what kind of feature can be added without degrading performance even further.

That being said, this project now is a hard fork, so we will have the freedom to do something more radical without worrying about breaking UIM user's sites,

AutisticShark commented 6 months ago

30