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

How to Implement Custom Time-Based Notifications for Users? #1574

Open
zhanchen18 opened this issue Nov 25, 2024 · 3 comments
Open

How to Implement Custom Time-Based Notifications for Users? #1574

zhanchen18 opened this issue Nov 25, 2024 · 3 comments
Labels
question How to do something

Comments

@zhanchen18
Copy link

I am working on a feature where users can set custom reminders (e.g., "Remind me to do something in 1 hour"), and the system should send a notification to the client at the specified time.

@JamesChenX
Copy link
Member

users can set custom reminders (e.g., "Remind me to do something in 1 hour")

If you want the client to be able to CRUD the custom settings, you can use custom-settings. In simple words, you can support custom settings (e.g. Reminder) by just modifying the server properties and without changing the source code.

By the way, you don't have to CRUD the custom settings via turms servers; you can implement this feature on your own application server too if you want.

the system should send a notification to the client at the specified time

There are two ways to support this feature.

  1. (Recommended) Your client can read the custom setting to know whether the reminder is enabled. If enabled, your client can query some data from servers according to your business requirements.

    btw, we do have a plan to support querying all kinds of notifications from servers (e.g. friend requests created/deleted/updated notifications), but the feature will come months later.

  2. Implement your plugin
    For details, please read custom plugins.
    In this way, you can do anything you want without modifying the source code of Turms servers.

e.g.

  • Implement your own im.turms.gateway.infra.plugin.extension.UserOnlineStatusChangeHandler
  • Set up a change stream to the collection user_setting to detect if the reminder setting is enabled. And start a periodic timer to query the last notification time from Redis. If the time difference is larger than 1 hour, send a notification to the online users.

@JamesChenX JamesChenX added the question How to do something label Nov 26, 2024
@zhanchen18
Copy link
Author

If you want the client to be able to CRUD the custom settings, you can use custom-settings.

How to set UserSettingsProperties?I not found

@JamesChenX
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question How to do something
Projects
None yet
Development

No branches or pull requests

2 participants