Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Questions on plugin structure #1

Closed
scottleedavis opened this issue Aug 14, 2018 · 0 comments
Closed

Questions on plugin structure #1

scottleedavis opened this issue Aug 14, 2018 · 0 comments
Assignees

Comments

@scottleedavis
Copy link
Owner

  1. is there a persistent store available via the rpc interface? (server-side plugin portion) For the java remind integration, I used a database with two tables defined. I don't think keeping reminders in memory alone is a good idea.
  2. Can Timezone be determined per user interaction through the server-side rpc? One fatal flaw in the java remind integration is that it runs only one timezone, which needs to be configured for each instance, and certainly doesn't change per user.
  3. Can server commands determine what user triggered them? It didn't seem a user object was available ( https://github.com/mattermost/mattermost-plugin-demo/blob/master/server/command_hooks.go ).
  4. What is the best approach to scheduling events in the plugin structure? In the java remind integration, a separate scheduler thread runs in the background every second checking for anything to 'remind'. (I am open to a better scheduling strategy).

plugin API for key-value pairs like KVSet, KVGet, KVDelete, maybe give it a try and see if it works for you.
Yes, on your custom API, you'll be able to get the user ID and get the profile from it, like:

func (p *Plugin) customAPI(w http.ResponseWriter, r *http.Request) {
userID := r.Header.Get("Mattermost-User-ID")
user, err := p.API.GetUser(userID)
// handle error
// do something with user object or user.Timezone
}

Yes, *model.CommandArgs includes UserId where you can use to get the user object from it, like:
func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
user, err := p.API.GetUser(args.UserId)
// handle error
// do something with user object
}

Maybe look at the built-in /echo command although it's in memory. I'm guessing, the same can be applied to /remind.

Yes, there's a persistent KV store. Look at the KVGet, KVStore and KVDelete APIs: https://developers.mattermost.com/extend/plugins/server/reference/#API.KVSet

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant