Set post custom field when composing

I am working on a plugin that should allow users to create specially flagged posts when pressing a button in the topic view. The post flag is just a boolean value. This is for interaction with an external tool. Currently, I have solved the following:

  1. I have added a custom action that opens the composer when the user presses the new button. Currently, the action is added by:
  api.modifyClass('controller:topic', {
    actions: {
      postFlagged(post) {
  1. I have added a custom field to the Post class and added it to the serializer. The field shows up in the serialized json as expected:
Post.register_custom_field_type('my_flag', :boolean)

add_to_serializer(:post, :my_flag, false) do
  1. I can add a method to the composer and have the value stored for the flag show up via handlebars template:
  api.modifyClass('model:composer', {
    flag: function() {
      return this.get('post.my_flag');

Now, my problem is that I have no idea how to set my custom field flag in the composer. How do I do that?

I am not sure if we allow shipping this to post creator via the controller even.

This is particularly tricky cause we don’t allow end users to set post custom fields so you would need to introduce some sort of whitelist.

Every way I can think of that involves solving this is either pretty hacky or involves lots of core work.

I think simplest thing you can do for now is an extra http req after the post is saved to your plugin controller to set the field.

The simplest thing would be to include an extra tag in the post.


^ doesn’t even require a plugin; you can use a [tag] if you make a plugin.


Yeah, but it would be pretty easy for our users to accidentally delete that from the post, plus the external system will need to scan the body of all posts to find the flag, which I believe will be too inefficient.