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?
AI 生成的摘要
Updating and saving topic on button press results in 404 not found
A plugin is attempting to update and save a topic using topic.save(props), but this results in a 404 not found error. The issue is due to Discourse trying to PUT at /topics/:topic_id instead of /t/:topic_id.
Janno_Liivak suspects this might be a bug, but after further investigation, he thinks it might be an issue with his plugin code.
He tries changing his code to Discourse.Topic.update(topic, props), which resolves the error but doesn’t save changes to the database.
After finding a missing logic in his plugin code and making a change to Discourse, Janno_Liivak creates a pull request (PR #4698) to address the issue.
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.
This is my plugin where I get this behaviour:
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 ![]()
Can somebody please point me a right direction? …Please
I kind of feel like I’m having a conversation with myself ![]()
Anyway … Found a missing logic in my plugin code, BUT … also had to change Discourse. Created PR Create correct topic path for REST adapter by jannolii · Pull Request #4698 · discourse/discourse · GitHub