Read custom json data in mattermost server to plugin

Hi,

I have a reactjs app that will open mattermost window externally by a user-click on a button, in which it has a mattermost plugin loaded. The plugin will need initial data from the reactjs app. For now, I can not find a way to reference the data from the reactjs app, so have to use url params to store data when open window. When user open the plugin, it will get data from those url-params. The problem is when user select another channel, then the URL is changed and the params are gone. So, What I am looking for are any of the below:

  1. is there a way to enable the plugin to read json data file, which is stored within mattermost server? This means if we want, we can change the data anytime and restart the server only, no build anything.

  2. OR is there a way to post some custom data to mattermost server and the plugin can retreive it later?

I would like to know if anyone have any insight / suggestion on either one or both of the items listed above, please help me out.

Thanks,
Charlie

Why not set cookies? And read the data from the cookies?

Hi, I have tried cookies set in the main app and get them back from the plugin window. It works fine but then we use apache to do mod_rewrite for Proxying for the mattermost server and seems like all cookies are wiped out and have to use url params to embed values. So, I am thinking about either the plugin can read a json file located somewhere in mattermost server or the plugin so we can change it without the need of a new build for the plugin. Or we can send some custom json data together when create a new channel using Client4 but seems that is lost. Any suggestion ?

Thanks,
Charlie

1 Like

That should be doable, to use a JSON file, I’m aware that you can call JSON files located in each plugin’s file folder in the mattermost codebase when it’s installed, so that could be how you can call JSON.

Yes, I have tried that and it works fine. I see there is an attr. calls “props” and I fill out that with custom json and able to retrieve it. But user must be with manage_system permission. I can not do that reading with a normal user who is mostly the user to use the plugin.

Have you created a bot account for the plugin? You should be able to do that, and if nothing else you can do it manually into the SQL database.

Sounds good to me now. Will try and see.

Thank you,
trancha

1 Like