Updating and saving topic on button press results in 404 not found

I have a plugin which places a button after main buttons. When pressing a button I would like to update topic and save it. But topic.save(props); results in 404 not found. Debugging reveals that Discourse is trying to PUT at /topics/:topic_id instead of /t/:topic_id. Is there something I’m doing wrong or is it a bug?

Hmm do you know which part of the code base is trying to hit the /topics/:topic_id route?

Yes. It’s a rest adapter’s pathFor(store, type, findArgs) {…}. It will be called through store model’s update() method (which is called from rest model’s update() method.

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/models/rest.js.es6#L8-L30

This is my plugin where I get this behaviour:
https://github.com/jannolii/discourse-bump-topic/blob/master/assets/javascripts/discourse/connectors/after-topic-footer-main-buttons/bump-topic.js.es6#L6

1 Like

I have a feeling that I’m doing something wrong here (namely in mu plugin code which I pointed out above). Should I do rather somethink like:

Discourse.Topic.update(topic, props);

No? Yes?
Kind of works … no error with this change … but nothing get’s saved also into the database :frowning:

Can somebody please point me a right direction? …Please

1 Like

I kind of feel like I’m having a conversation with myself :wink:

Anyway … Found a missing logic in my plugin code, BUT … also had to change Discourse. Created PR https://github.com/discourse/discourse/pull/4698

2 Likes