Skip to content

🚀 Enhancement: query messages by user and target #8974

Description

@dhonig-weizmann

🔖 Enhancement description

Enable querying of Messages by userId or targetId.

🎤 Pitch

In my use-case, I would like to check if I have already scheduled a push notification for a specific user. Ideally, I would like to list all messages of status scheduled for the given user or target. Currently, I cannot do that as the allowed attributes for filtering are: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType (according to your docs).
The current workaround is for me to keep track of the messageIds for each user, which is unnecessary duplication as AppWrite already does this for me - I just can't query it.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Activity

  1. added
    enhancement
    on Nov 14, 2024
  2. added
    product / messaging
    on Nov 14, 2024
  3. danielle-h commented on Nov 17, 2024

    @danielle-h

    An additional use case: I would like to cancel all push notifications if a user has opted out of them.

  4. Jstreetman commented on Nov 24, 2024

    @Jstreetman

    An additional use case: I would like to cancel all push notifications if a user has opted out of them.

    I think one way to opt out of push notifications, would be to have a boolean attribute in a "Users Collection" which is true if such a user has enabled push notifications. to cancel, you would have to update the document by the Id of the user from the collection , and set the boolean to false, also you have have to update the messaging as well, NOTE if it is connected to the user you could seamlessly update it. Hope this helps, let me know if ya have any questions .

  5. danielle-h commented on Nov 24, 2024

    @danielle-h

    @Jstreetman, thank you for the suggestion. If I understand correctly, I would still need to keep track of all the scheduled messageIds of the user, correct?
    In the meantime, I am removing the push target when a user opts out. This causes the messages to fail delivery, but the attempt is still made.
    Thanks

  6. danielle-h commented on Nov 26, 2024

    @danielle-h

    An additional problem: if I keep track of messageIds in the front end, then someone who uninstalls and reinstalls will still get the previous push notifications. (it defines as the same push target, apparently). I am aware that there are workarounds for this as well (keeping data, saving messageIds in appwrite, etc), but this is a needlessly complex solution compared to querying by userId.

  7. stnguyen90 commented on Dec 10, 2024

    @stnguyen90
    Contributor

    @danielle-h, when you're creating the message, are you putting the user's ID in the users param?

  8. danielle-h commented on Dec 11, 2024

    @danielle-h

    @stnguyen90 Yes. This is the code:

    Message result = await messaging.createPush(
              messageId: ID.unique(),
              title: "Time to smell!",
              body: "Tap to tell us what you smell!",
              users: [userId], //user to push to
              data: {"time": time}, //time set for notification
              tag: "Smellit_notification",
              scheduledAt: time,
            );
    
  9. dhonig-weizmann commented on May 18, 2025

    @dhonig-weizmann
    Author

    Is there any progress on this issue? It's making our code needlessly complex, and creating a worse user experience as we cannot check if a user already has scheduled notifications.

  10. removed
    enhancement
    on Sep 3, 2025
  11. bhardwajparth51 commented on Apr 7, 2026

    @bhardwajparth51
    Contributor

    Is this still open to work. I'd love to work on this

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / messaging

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions