Unverified Commit 95f70fde authored by Joram Wilander's avatar Joram Wilander Committed by GitHub
Browse files

Merge pull request #2 from mattermost/mm-11026

MM-11026 Migrate to use plugin v2 system coming in Mattermost 5.2
parents 25f7aa81 bbd02135
hash: 5c78b0337c128afa41779ef112bf41aea7a92c9094e13fab7223d831de386916
updated: 2017-12-10T01:37:04.279381-06:00
hash: a3877dc6f3d4f71229131fe319d16d3feeb34c75df413df9426951a726dc64a6
updated: 2018-07-15T21:26:16.18042093-04:00
imports:
- name: github.com/alecthomas/log4go
version: 3fbce08846379ec7f4f6bc7fce6dd01ce28fae4c
repo: https://github.com/mattermost/log4go.git
- name: github.com/golang/freetype
version: e2365dfdc4a05e4b8299a783240d4a7d5a65d4e4
subpackages:
- raster
- truetype
- raster
- name: github.com/golang/protobuf
version: 14aad3d5ea4c323bcd7a2137e735da24a76e814c
subpackages:
- proto
- ptypes
- ptypes/any
- ptypes/duration
- ptypes/timestamp
- name: github.com/gorilla/context
version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42
- name: github.com/gorilla/mux
version: 7f08801859139f86dfafd1c296e2cba9a80d292e
version: e3702bed27f0d39777b0b37b664b6280e8ef8fbf
- name: github.com/gorilla/websocket
version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b
version: 5ed622c449da6d44c3c8329331ff47a9e5844f71
- name: github.com/hashicorp/go-hclog
version: ff2cf002a8dd750586d91dddd4470c341f981fe1
- name: github.com/hashicorp/go-plugin
version: e8d22c780116115ae5624720c9af0c97afe4f551
- name: github.com/hashicorp/yamux
version: 3520598351bb3500a49ae9563f5539666ae0a27c
- name: github.com/kballard/go-shellquote
version: cd60e84ee657ff3dc51de0b4f55dd299a3e136f2
version: 95032a82bc518f77982ea72343cc1ade730072f0
- name: github.com/mattermost/mattermost-server
version: 4c17bdff1bb871fb31520b7b547f584c53ed854f
version: 62c64594ccaa0e634023b358758f2a6bf04164ad
subpackages:
- model
- plugin
- plugin/rpcplugin
- mlog
- utils/jsonutils
- utils/markdown
- name: github.com/mitchellh/go-testing-interface
version: a61a99592b77c9ba629d254a693acffaeb4b7e28
- name: github.com/nicksnyder/go-i18n
version: 0dc1626d56435e9d605a29875701721c54bc9bbd
version: f6ac3d9cf0c4b6a32527779e992ebde26bd3d948
subpackages:
- i18n
- i18n/bundle
- i18n/language
- i18n/translation
- name: github.com/oklog/run
version: 6934b124db28979da51d3470dadfa34d73d72652
- name: github.com/pborman/uuid
version: e790cca94e6cc75c7064b1332e63811d4aae1a53
version: c65b2f87fee37d1c7854c9164a450713c28d50cd
- name: github.com/pelletier/go-toml
version: 4e9e0ee19b60b13eb79915933f44d8ed5f268bdd
version: 603baefff989777996bf283da430d693e78eba3a
- name: github.com/pkg/errors
version: f15c970de5b76fac0b59abb32d62c17cc7bed265
version: 816c9085562cd7ee03e7f8188a1cfd942858cded
- name: go.uber.org/atomic
version: 1ea20fb1cbb1cc08cbd0d913a96dead89aa18289
- name: go.uber.org/multierr
version: 3c4937480c32f4c13a875a1829af76c98ca3d40a
- name: go.uber.org/zap
version: 7e7e266a8dbce911a49554b945538c5b950196b8
subpackages:
- zapcore
- internal/bufferpool
- buffer
- internal/color
- internal/exit
- name: golang.org/x/crypto
version: 94eea52f7b742c7cbe0b03b22f0c4c8631ece122
version: a49355c7e3f8fe157a85be2f77e6e269a0f89602
subpackages:
- bcrypt
- blowfish
- name: golang.org/x/image
version: e5db4c466346ada62f27934dab20e4b6f6bda285
version: c73c2afc3b812cdd6385de5a50616511c4a3d458
subpackages:
- font
- math/fixed
- name: golang.org/x/net
version: d0887baf81f4598189d4e12a37c6da86f0bba4d0
subpackages:
- context
- http2
- trace
- http/httpguts
- http2/hpack
- idna
- internal/timeseries
- name: golang.org/x/sys
version: ac767d655b305d4e9612f5f6e33120b9176c4ad4
subpackages:
- unix
- name: golang.org/x/text
version: 0605a8320aceb4207a5fb3521281e17ec2075476
subpackages:
- secure/bidirule
- unicode/bidi
- unicode/norm
- transform
- name: google.golang.org/genproto
version: e92b116572682a5b432ddd840aeaba2a559eeff1
subpackages:
- googleapis/rpc/status
- name: google.golang.org/grpc
version: ce6ee6b031cb9e88a81e8d4d502d5b3eafb27f98
subpackages:
- credentials
- health
- health/grpc_health_v1
- balancer
- balancer/roundrobin
- codes
- connectivity
- encoding
- encoding/proto
- grpclog
- internal
- internal/backoff
- internal/channelz
- internal/envconfig
- internal/grpcrand
- internal/transport
- keepalive
- metadata
- naming
- peer
- resolver
- resolver/dns
- resolver/passthrough
- stats
- status
- tap
- balancer/base
- name: gopkg.in/natefinch/lumberjack.v2
version: a96e63847dc3c67d17befa69c303767e2f84e54f
- name: gopkg.in/yaml.v2
version: 287cf08546ab5e7e37d55a84f7ed3fd1db036de5
version: 5420a8b6744d3b0345ab293f6fcba19c978f1183
testImports:
- name: github.com/davecgh/go-spew
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73
subpackages:
- spew
- name: github.com/pmezard/go-difflib
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
version: 792786c7400a136282c1664665ae0a8db921c6c2
subpackages:
- difflib
- name: github.com/stretchr/testify
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
version: f35b8ab0b5a2cef36673838d662e249dd9c94686
subpackages:
- assert
- require
......@@ -6,16 +6,12 @@ import:
- package: github.com/gorilla/mux
version: ^1.6.0
- package: github.com/kballard/go-shellquote
- package: github.com/mattermost/mattermost-server
version: ^4.5.0-rc1
subpackages:
- plugin
- plugin/rpcplugin
- package: golang.org/x/image
subpackages:
- font
- math/fixed
- package: gopkg.in/yaml.v2
- package: github.com/mattermost/mattermost-server
testImport:
- package: github.com/stretchr/testify
version: ^1.1.4
......
......@@ -10,10 +10,9 @@ import (
"strings"
"github.com/gorilla/mux"
"github.com/kballard/go-shellquote"
shellquote "github.com/kballard/go-shellquote"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/plugin/rpcplugin"
"github.com/mattermost/mattermost-plugin-memes/meme"
"github.com/mattermost/mattermost-plugin-memes/memelibrary"
......@@ -101,20 +100,22 @@ func serveTemplateJPEG(w http.ResponseWriter, r *http.Request) {
}
type Plugin struct {
plugin.MattermostPlugin
router *mux.Router
}
func (p *Plugin) OnActivate(api plugin.API) error {
func (p *Plugin) OnActivate() error {
p.router = mux.NewRouter()
p.router.HandleFunc("/templates/{name}.jpg", serveTemplateJPEG).Methods("GET")
return api.RegisterCommand(&model.Command{
return p.API.RegisterCommand(&model.Command{
Trigger: "meme",
AutoComplete: true,
AutoCompleteDesc: "Renders custom memes so you can express yourself with culture.",
})
}
func (p *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Mattermost-User-Id") == "" {
http.Error(w, "please log in", http.StatusForbidden)
return
......@@ -123,7 +124,7 @@ func (p *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
p.router.ServeHTTP(w, r)
}
func (p *Plugin) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
input := strings.TrimSpace(strings.TrimPrefix(args.Command, "/meme"))
if input == "" {
......@@ -182,6 +183,6 @@ func main() {
os.Exit(1)
}
} else {
rpcplugin.Main(&Plugin{})
plugin.ClientMain(&Plugin{})
}
}
......@@ -3,4 +3,4 @@ backend:
executable: plugin.exe
name: Memes
description: Gives you the ability to quickly create and post memes via a /meme slash command.
version: '0.1'
version: '1.0'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment