I could swear this worked in my early testing, as it’s key to my workflow: I could tag an existing post, and users with watching_first_post on that tag would get a notification.
I’ve now found it does not work this way (…anymore…?)
Or maybe it’s being ignored when there are already reply posts under that topic?
I imagine I could move topics to a category where everyone is ‘watching first post’, but…
Are notifications only triggered at topic creation?
I’m not sure if the presence of reply posts would cause the ‘first post’ trigger to be ignored.
I really wanted to keep related topics in one category, and “escalate” some via tag.
I’m willing to run a script to kick off notifications each time, but the Askbot couldn’t help me create one that works.
That’s pretty definitive, so I must be mis-remembering, and had created test topics with the tracked tag present.
Oh no – I’m not suggesting that setting a user to ‘watch first post’ via tag should do anything retroactive.
But surely it’s common for posted topics to be tagged by staff later. I’d just somehow imagined that when a ‘watch first post’ tag is applied to an existing topic, it would generate a notification of that topic for users already WFP-ing the tag.
I’m still working with Askbot to come up with an ad-hoc script for these occasions…
After about 60 iterations, Askbot and I have a rails script almost working.
The script below – for topic 239 and tag ‘tagtest’ – generates the expected “New Topic” notifications with the correct topic title, and generates related emails.
Some elements seem inert (message: and display_username: don’t appear in any output) but it nearly works.
The showstopper is the emails don’t arrive with the actual topic title in the header. It comes through as " %{topic_title} ". topic_title is apparently not a valid field for the Notification method, so I’m not sure what’s the minimum code neccessary to get it into the email. (Askbot tried adding ever-more elaborate email methods, with ever-increasing errors.)
If someone could help with that detail, it would keep me afloat until I learn how to clean this up properly…!
topic_id = 239
Tag.where(name: 'tagtest').each do |tag|
TagUser.where(tag_id: tag.id, notification_level: TagUser.notification_levels[:watching_first_post]).each do |tag_user|
user = User.find(tag_user.user_id)
puts "Username: #{user.username}, ID: #{user.id}"
# Fetch the topic title
topic = Topic.find(topic_id)
topic_title = topic.title
# Create a notification for the topic
Notification.create!(
user_id: user.id,
notification_type: Notification.types[:watching_first_post],
topic_id: topic_id,
post_number: 1, # Assuming you want to notify about the first post of the topic
data: {
message: 'You have a new notification for a topic you are watching.',
display_username: 'system'
}.to_json
)
end
end
Yeah, I just think generally recategorizing is far rarer that re-tagging so the scale of the problem is somewhat mitigated. Any chance you can do a quick screenshot of what happens when you bulk re-categorize 3 topics to a watch-first?
I wouldn’t dream of bulk tagging 500 topics, but curious, would it cause more strain than posting to an Announcements category that everyone Watches? (Edit: Oops, Moin posted while I was composing.)
My own use case is maybe one post a week to “escalate” via notification emails.
It feels similar to earlier discussion about recategorized topics: (Edit: which you already know, sorry.)
I’m just aiming to use a tag rather than having two categories for similar topics. (They belong together, but a few are, after posting, deemed worthy of sending out to our quiet, sometimes email-only users.)
FWIW Adding a tag to an existing topic should send a notification to anyone Watching First Post for that tag.
I’ve just tested it on my test site (3108e3a6b6) and it still seems to be working correctly.
Just to check, did you change the disable tags edit notifications admin setting at any point? (And disable category edit notifications for the category version).
I had forgotten those settings existed. I imagine when I disabled them I was thinking only of notifications like “an admin has added a tag or changed the category of your topic” – not actions like Watching or WFP notifications.
I think there may still be some inconsistencies, as Watching a category seemed to override disable category edit modifications, while WFP did not. As penance, I will test this more thoroughly and follow up with a couple of other people I pinged on the subject.