Approach to mute notifications in forum-style app

I have built a forum app. Each main post is captured in one table. Replies to each main post are in a second table, connected by a relation to the row ID of the main post in the main post table. When a person replies to a post the original poster and anyone who has replied to the post receive a notification. This is accomplished by: In the main table, a query identifies everyone who has replied to the post and then a join column creates a common separated list of emails of each user who has replied, which is fed into the bcc: of the email that is sent when they submit their reply.

I’m trying to figure out the best approach to allow a user mute notifications for a post that they have responded to. So far, the approach I have taken is to use a template column to combine the main-post row id and the user’s email address to create a unique key (I.e. fuE1ogQiTBOoZO-2unb.Pw-marie@example.com) in the replies table. When a user wants to mute updates, it clicks a button in the post screen which writes that value and their email address to a third table. I then use that with a query in the main post table to basically create a second column of emails (similar to the approach above) to exclude those users where they have an entry in the third table muting notifications for that post.

That works fine but I’m wondering if :

  1. There is a cleaner way than my approach because it’s a little convoluted to use two different queries to accomplish this.

2. More importantly, (and possibly a consequence of my approach) I can’t figure out how to give the user the ability to unmute. What I want is to have one “mute” action that is displayed only to those users that have replied to the post (it doesn’t make sense to mute the post if you haven’t replied) and only if they haven’t yet muted it. This works. What I can’t figure out how to do is to create an action that displays when they’ve muted the post that allows them to “unmute”…to basically delete the entry in the third table and undo the “mute”. The delete row action can’t reference “this row” because that is a row in the replies or main post table. I tried to use a relation between the third table and the replies table using the unique key and use the relation in place of “this row” but so far that doesn’t work. Selecting that makes the action disappear, presumably because the relation is blank.

Welcome thoughts on one or both…

Update: I figured out a solution to number 2 by writing the unique value to the user table temporality and then using a relation between the user table and table 3 to target the correct row to delete. Still welcome feedback on whether there is a more straight forward approach.

Your approach is actually solid combining the post ID + user email as a unique key and storing it in a third table is a reliable way to handle “mute” functionality. It ensures flexibility and avoids breaking the notification logic.

That said, if you want to simplify, another option is to add a boolean “Muted” flag in the replies table (or a user-specific column) tied to each post/user combo. This way, instead of managing a separate table and queries, you can just filter out users marked as “Muted” when generating your email list.

Both methods work yours gives more explicit control, while the boolean flag keeps it leaner. If you’d like, I can help restructure this so it’s cleaner and easier to maintain long term.

Possible way to use less rows:

  • Have a basic multiple texts column to store “muted” emails in the same Posts table. Let’s call this “Muted Array”.
  • Have a “Make Array” column to combine the array above with the signed-in user’s email, let’s call this “Add Muted Array”. When users want to mute, your button would set “Add Muted Array” to “Muted Array”.
  • Have a “Remove Element from Array” column to remove signed-in user’s email from the “Muted Array”. Let’s call this “Remove Muted Array”. When users want to unmute, your button would set “Remove Muted Array” to “Muted Array”.
  • When a notification needs to be sent, I imagine you have an array of people who needs to be notified (without considering the muted part). You convert that to an array, use the Remove Elements column to remove “Muted Array” from that list, and you have a final array to send.
1 Like

Oh this is good. Let me try implementing this. Thanks @ThinhDinh!

1 Like