For workflow, we'll need a two twists on notifications.
1) Notify a subset.
We want to let you subscribe to notifications on all actions that you're assigned to. That's a notification type where any particular notification should only go out to a subset of the people who've requested it. So when we send out the notification, we'll pass along the list of people who are assigned to the next action in the workflow, and we want notifications to only send to those who have a request, *and* are in that list. Makes sense?
Unfortunately, the notifications package doesn't work that way. It has (a) notification types, (b) requests for notifications of that type, (c) notifications, and (d) users who already received a given notification.
That's how it knows who to send to: Everybody who requested this notification type (for this object), and who haven't yet received a notification.
How should we work around this?
One way is to reverse the data model, so instead of notification_user_map holding users already notified, it would hold users _waiting_ to be notified. I suspect the reason they didn't do this from the start was that they'd rahter have the overhead in a background thread than in the request thread that inserts the notification.
Alternatively, we could insert 'fake' rows into notification_user_map for all the users that *shouldn't* be notified this time.
Other suggestions?
2) Don't notify people twice
This is similar. The problem is that you can subscribe to the same type of event at many levels. Forums is a good example. Currently, you can subscribe to an entire forum, or a single thread.
What happens, then, when someone posts a message and you're subscribed to both forum and thread? You get notified twice!
That's not what I want. I want *one* event to result in *one* notification. Which one will be predetermined, and will typically be the most specific one first, i.e., the thread one.
This is similar, in that we want to send out notifications, but we want to limit the recipients to a subset of the ones who requested notifications.
Jeff? Don? Who else hacked on notifications or has an idea of what the best way to fix this is?
I'd assumed it worked the other way around, so I thought this was fairly trivial. Turns out it's not.
/Lars