I’m migrating away from the deprecated api.modifyClass("model:composer", ...).
My current override of Composer#save conditionally changes the save behavior, but otherwise needs to call super.save(opts).
I see the new addModelMethod / addModelCallback APIs, but I can’t find an example in core of using addModelMethod to override an existing method while retaining access to the original implementation.
Is addModelMethod intended for overriding existing model methods like this? If so, how should a plugin delegate to the original save() implementation?
Or is there another extension point that should be used for this Composer use case?
Thanks! I’m already using composer-service-cannot-submit-post — it handles the service-level check. But the composer model’s save() also checks cantSubmitPost, which includes missingReplyCharacters > 0, so an empty body is still blocked there.
onAppEvent("post:created") is too late because the post never gets created, and serializeOnCreate only adds fields to the request, so it doesn’t help with the body-length validation.
So the remaining issue is bypassing missingReplyCharacters / cantSubmitPost for the first post. Is there a supported extension point for this?
The best thing would be to add a new hook to Discourse core which allows you to achieve what you need in a supported way. How about something like this: