Mattermost-server: Plugin framework: Add API methods

Created on 25 Sep 2018  路  21Comments  路  Source: mattermost/mattermost-server

If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.


Below are a list of methods available in model/client4.go, the Go REST API driver for Mattermost, that do not have equivalents in the plugin API. If you would like to work on adding an equivalent plugin API, please comment on this issue letting us know which API you are working on.

Read about adding to the plugin API here https://developers.mattermost.com/contribute/server/plugins/. Most of these methods should have fairly simple equivalents in the app package, making them trivial to implement.

You'll want to look at these files:

If you have any questions or would like feedback, feel free to ask in the Developer Toolkit channel on our Mattermost community instance.

Help wanted ticket created by @jwilander.

Original list created by @SmartHoneybee.

  • "Yes": Without these functions plugin, development is hard (use case: interface with other IM service).
  • "Maybe": Nice to have. Would allow implementing more features.
  • "Interesting": Nothing I'm interested in, but maybe others?
Yes
Maybe
Interesting
  • [ ] GetPostsBetween to get posts in a channel lying in a specific date range
  • [x] CreateDirectChannel(userId1, userId2 string) (*Channel, *Response)- https://github.com/mattermost/mattermost-server/pull/9848~~
  • [ ] CreateGroupChannel(userIds []string) (*Channel, *Response)
  • [x] DisablePlugin(id string) (bool, *Response) - https://github.com/mattermost/mattermost-server/issues/9740
  • [ ] DoApiDelete(url string) (*http.Response, *AppError)
  • [ ] DoApiGet(url string, etag string) (*http.Response, *AppError)
  • [ ] DoApiPost(url string, data string) (*http.Response, *AppError)
  • [ ] DoApiPut(url string, data string) (*http.Response, *AppError)
  • [ ] DoApiRequest(method, url, data, etag string) (*http.Response, *AppError)
  • [ ] DoPostAction(postId, actionId string) (bool, *Response)
  • [ ] DoUploadFile(url string, data []byte, contentType string) (*FileUploadResponse, *Response)
  • [x] GetFile(fileId string, download bool) ([]byte, *Response)
  • [ ] GetFilePreview(fileId string, download bool) ([]byte, *Response)
  • [ ] GetFileThumbnail(fileId string, download bool) ([]byte, *Response)
  • [x] EnablePlugin(id string) (bool, *Response) - https://github.com/mattermost/mattermost-server/issues/9740
  • [ ] ExecuteCommand(channelId, command string) (*CommandResponse, *Response)
  • [ ] GetChannelMembersForUser(userId, teamId, etag string) (*ChannelMembers, *Response)
  • [x] GetPluginStatuses() (PluginStatuses, *Response) - https://github.com/mattermost/mattermost-server/issues/9740
  • [x] GetPlugins() (*PluginsResponse, *Response) - https://github.com/mattermost/mattermost-server/issues/9740
  • [ ] GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) ([]*Channel, *Response)
  • [x] GetTeamIcon(teamId, etag string) ([]byte, *Response) - https://github.com/mattermost/mattermost-server/pull/9837
  • [ ] GetTeamMembersByIds(teamId string, userIds []string) ([]*TeamMember, *Response)
  • [ ] GetTeamMembersForUser(userId string, etag string) ([]*TeamMember, *Response)
  • [ ] GetTeamStats(teamId, etag string) (*TeamStats, *Response)
  • [ ] GetTeamUnread(teamId, userId string) (*TeamUnread, *Response)
  • [x] GetUsers(page int, perPage int, etag string) ([]*User, *Response)
  • [ ] GetUsersByIds(userIds []string) ([]*User, *Response)
  • [ ] GetUsersNotInChannel(teamId, channelId string, page int, perPage int, etag string) ([]*User, *Response)
  • [ ] GetUsersNotInTeam(teamId string, page int, perPage int, etag string) ([]*User, *Response)
  • [ ] GetUsersWithoutTeam(page int, perPage int, etag string) ([]*User, *Response)
  • [x] GetWebappPlugins() ([]*Manifest, *Response)
  • [ ] ImportTeam(data []byte, filesize int, importFrom, filename, teamId string) (map[string]string, *Response)
  • [ ] InviteUsersToTeam(teamId string, userEmails []string) (bool, *Response)
  • [ ] ListCommands(teamId string, customOnly bool) ([]*Command, *Response)
  • [x] RemovePlugin(id string) (bool, *Response) - https://github.com/mattermost/mattermost-server/issues/9740
  • [x] RemoveTeamIcon(teamId string) (bool, *Response) -https://github.com/mattermost/mattermost-server/pull/9847
  • [ ] SaveReaction(reaction *Reaction) (*Reaction, *Response)
  • [ ] SearchChannels(teamId string, search *ChannelSearch) ([]*Channel, *Response)
  • [ ] SearchPostsWithMatches(teamId string, terms string, isOrSearch bool) (*PostSearchResults, *Response)
  • [x] SearchPostsWithParams(teamId string, params *SearchParameter) (*PostList, *Response)
  • [ ] SearchTeams(search *TeamSearch) ([]*Team, *Response)
  • [ ] SendPasswordResetEmail(email string) (bool, *Response)
  • [x] SetProfileImage(userId string, data []byte) (bool, *Response) - https://github.com/mattermost/mattermost-server/pull/9831
  • [x] SetTeamIcon(teamId string, data []byte) (bool, *Response) - https://github.com/mattermost/mattermost-server/pull/9840
  • [ ] UpdateCommand(cmd *Command) (*Command, *Response)
  • [ ] UploadPlugin(file io.Reader) (*Manifest, *Response)
AreIntegrations Help Wanted TecGo

Most helpful comment

Thanks, @jwilander, I'll open that PR and will raise PR for other methods soon. :smiley:

All 21 comments

Thank you @SmartHoneybee!

I created an improvement ticket for this here: https://mattermost.atlassian.net/browse/MM-12312.

Thanks. :)

After reading through #9404: maybe also add a MessageHasBeenDeleted(c *plugin.Context, post *model.Post) hook? Then people could develop and use a plugin to delete old files, if they want.

Sure thing! I added it to the list in the Jira ticket.

Awesome, thanks for this @SmartHoneybee!!

What do you think about re-purposing this issue into a giant "help wanted" issue? I'm thinking make the bullet points into checkboxes and then people can just comment here with which API they're going to add

Maybe we start with the "Yes" and "Maybe" categories first

Hi,

feel free to edit, retitle, or reuse this issue however you see fit. :slightly_smiling_face:
"Help wanted" sound great, then people can pick what they need for their plugins.
(Just want to stress: function selection and categories are IMHO. Feedback welcome.)

Regards,
Bee

Thanks! Done

I'd like to work on this.

Awesome, thank you @Akash4927 :tada:

Hi @Akash4927, which methods are you going to work on?

Hi @jwilander, I'd like to work on the methods present in Yes section

@SmartHoneybee @jwilander Do I have to add new member to PluginAPI struct to call the methods in model/client4.go?

type PluginAPI struct {
    id       string
    app      *App
        client   *model.Client4
    logger   *mlog.SugarLogger
    manifest *model.Manifest
}

If yes, then I have to change at all places where NewPluginAPI() method has been called.

@Akash4927 you're not actually calling the Client4 methods from the plugin. You're adding equivalent methods to the plugin API.

For example, here's a PR adding some methods to the plugin API: https://github.com/mattermost/mattermost-server/pull/9022

Thanks, @jwilander, Can you please take a look at the PR https://github.com/mattermost/mattermost-server/pull/9525/files

Am I on the right path?

That's the exact right path :+1:

Thanks, @jwilander, I'll open that PR and will raise PR for other methods soon. :smiley:

@Akash4927 We started adding individual help wanted tickets on the API methods so it's easier for community members to claim them.

If you're working on any of them, you can add a comment so others in the community know it's in progress :)

Added to the list: GetPostsBetween to get posts in a channel lying in a specific date range

@SmartHoneybee, thanks for getting the ball rolling on this front! Going forward, the plan will be to first revisit which of the remaining APIs we should port to the plugin API, and then create individual help-wanted tickets to match.

Was this page helpful?
0 / 5 - 0 ratings