Is there a way to edit posts with the API without notifying the user?

I want to add private tags to some posts via the API without notifying the users in any way. Adding tags works already, but it adds the pencil icon to the post and notifies the user that the topic has been edited.

It looks like there is a way to hide the pencil manually, but the user still receives a notification that the topic/post was edited, even if the revision is “hidden”.

Is there a way to update a topic (tags, category, etc.) both without showing a pencil icon and without notifying the user? (preferably with the API, but even manually)

The only thing that I’ve found so far is to go into the Rails console to do it:

ssh servername
cd /var/discourse
./launcher enter app
rails c

# then a bunch of rails stuff to find the 
# tag ID, topic ID and push the tag into 
# the topic and manually save the topic

If there isn’t a way to do it, I’ll just write a Ruby script that I can paste in the Rails console for now.

Bug Report

It also looks like there is a bug with the pencil icon. When I add a private tag to a topic (a tag that only admins can see), it adds the pencil icon to the first post, but when the test user (TL1) clicks on the orange pencil, it shows this message:

1 Like

I think if you use system user, it should not notify the user.

1 Like

Thanks for checking. I just tried it, and it didn’t seem to send a notification, but it still adds the pencil icon.

I think using the Append Tag option in the Bulk Actions adds the tag to the topic(s) silently without adding a pencil icon. You should be able to use the API to replicate that (if you use Reverse engineer the Discourse API you can see the endpoint and parameters you’ll need)

5 Likes

Thanks, that seems to work in the UI. I’ll try it with the API tomorrow.

In case anyone else is looking for it in the future:

PUT https://forum.example.com/topics/bulk

Form data copied from the browser console:

topic_ids%5B%5D=12345&operation%5Btype%5D=append_tags&operation%5Btags%5D%5B%5D=tagname

Decoded:

topic_ids[]=12345&operation[type]=append_tags&operation[tags][]=tagname

Update: it worked with the API too.

2 Likes