[in-bulletin] The "mail error: header To is required" error when adding new topic [5.2.2-B2]
In https://in-portal.atlassian.net/browse/INP-1017 the functionality was developed that allows users to events happened on website. As an example a feature was added that allows users to get email each time a topic/post in a given category or it's sub categories is added.
This is awesome feature, but appears that subscriptions aren't removed automatically, when:
associated user is deleted (if association was done to User ID and not Email directly)
associated item is deleted (e.g. post in a topic)
associated parent item is deleted (e.g. topic of the monitored post)
associated section was deleted (e.g. sub-section on the forum)
The removal of users and sections can be easily tracked in real time, but it's not that easy to track removal of item/parent item because subscriptions can be made to any item in the system and not only topics & posts.
Solution
change SQL returned by "OnGetEventSubscribersQuery" event to also include "UserEmail" column with value of "Users.Email" for that user
change "kEventManager::notifySubscribers" method to send email only when either of "SubscriberEmail" or "UserEmail" are not empty
create scheduled task, that will:
run once a day (e.g. at 00:00)
delete subscription records that doesn't match any existing records in db