Skip to content

Commit

Permalink
update mattermost package to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Oct 29, 2021
1 parent 1e4e39a commit ac7bf69
Show file tree
Hide file tree
Showing 15 changed files with 503 additions and 298 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -172,4 +172,4 @@ endif

# Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@cat Makefile | grep -v '\.PHONY' | grep -v '\help:' | grep -B1 -E '^[a-zA-Z0-9_.-]+:.*' | sed -e "s/:.*//" | sed -e "s/^## //" | grep -v '\-\-' | sed '1!G;h;$$!d' | awk 'NR%2{printf "\033[36m%-30s\033[0m",$$0;next;}1' | sort
@cat Makefile | grep -v '\.PHONY' | grep -v '\help:' | grep -B1 -E '^[a-zA-Z0-9_.-]+:.*' | sed -e "s/:.*//" | sed -e "s/^## //" | grep -v '\-\-' | sed '1!G;h;$$!d' | awk 'NR%2{printf "\033[36m%-30s\033[0m",$$0;next;}1' | sort
20 changes: 10 additions & 10 deletions build/deploy/main.go
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path/filepath"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mholt/archiver/v3"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -52,9 +52,9 @@ func deploy() error {
if adminUsername != "" && adminPassword != "" {
client := model.NewAPIv4Client(siteURL)
log.Printf("Authenticating as %s against %s.", adminUsername, siteURL)
_, resp := client.Login(adminUsername, adminPassword)
if resp.Error != nil {
return errors.Wrapf(resp.Error, "failed to login as %s", adminUsername)
_, _, err := client.Login(adminUsername, adminPassword)
if err != nil {
return errors.Wrapf(err, "failed to login as %s", adminUsername)
}

return uploadPlugin(client, pluginID, bundlePath)
Expand Down Expand Up @@ -83,15 +83,15 @@ func uploadPlugin(client *model.Client4, pluginID, bundlePath string) error {
defer pluginBundle.Close()

log.Print("Uploading plugin via API.")
_, resp := client.UploadPluginForced(pluginBundle)
if resp.Error != nil {
return errors.Wrap(resp.Error, "failed to upload plugin bundle")
_, _, err = client.UploadPluginForced(pluginBundle)
if err != nil {
return errors.Wrap(err, "failed to upload plugin bundle")
}

log.Print("Enabling plugin.")
_, resp = client.EnablePlugin(pluginID)
if resp.Error != nil {
return errors.Wrap(resp.Error, "Failed to enable plugin")
_, err = client.EnablePlugin(pluginID)
if err != nil {
return errors.Wrap(err, "Failed to enable plugin")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion build/manifest/main.go
Expand Up @@ -6,7 +6,7 @@ import (
"io/ioutil"
"os"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
)

Expand Down
8 changes: 4 additions & 4 deletions go.mod
@@ -1,13 +1,13 @@
module github.com/mattermost/mattermost-plugin-zoom

go 1.12
go 1.15

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/mattermost/mattermost-plugin-api v0.0.12
github.com/mattermost/mattermost-server/v5 v5.28.1
github.com/mattermost/mattermost-plugin-api v0.0.21
github.com/mattermost/mattermost-server/v6 v6.0.2
github.com/mholt/archiver/v3 v3.5.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.6.1
github.com/stretchr/testify v1.7.0
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
)
724 changes: 462 additions & 262 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin.json
Expand Up @@ -7,7 +7,7 @@
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-zoom/releases/tag/v1.5.1",
"icon_path": "assets/profile.svg",
"version": "1.5.1",
"min_server_version": "5.12.0",
"min_server_version": "5.37.0",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
Expand Down
4 changes: 2 additions & 2 deletions server/command.go
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/mattermost/mattermost-plugin-zoom/server/zoom"

"github.com/mattermost/mattermost-plugin-api/experimental/command"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/pkg/errors"
)

Expand Down
8 changes: 4 additions & 4 deletions server/http.go
Expand Up @@ -15,8 +15,8 @@ import (
"strings"
"time"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/pkg/errors"
"golang.org/x/oauth2"

Expand Down Expand Up @@ -290,8 +290,8 @@ func (p *Plugin) handleMeetingEnded(w http.ResponseWriter, r *http.Request, webh
return
}

_, err := w.Write([]byte(post.ToJson()))
if err != nil {
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(post); err != nil {
p.API.LogWarn("failed to write response", "error", err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/main.go
Expand Up @@ -4,7 +4,7 @@
package main

import (
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v6/plugin"
)

func main() {
Expand Down
13 changes: 9 additions & 4 deletions server/plugin.go
Expand Up @@ -9,13 +9,14 @@ import (
"path/filepath"
"sync"

"github.com/mattermost/mattermost-plugin-api/experimental/telemetry"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/pkg/errors"
"golang.org/x/oauth2"

pluginapi "github.com/mattermost/mattermost-plugin-api"
"github.com/mattermost/mattermost-plugin-api/experimental/telemetry"
"github.com/mattermost/mattermost-plugin-zoom/server/zoom"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
)

const (
Expand All @@ -34,6 +35,8 @@ type Plugin struct {

jwtClient zoom.Client

client *pluginapi.Client

// botUserID of the created bot account.
botUserID string

Expand All @@ -58,6 +61,8 @@ type Client interface {

// OnActivate checks if the configurations is valid and ensures the bot account exists
func (p *Plugin) OnActivate() error {
p.client = pluginapi.NewClient(p.API, p.Driver)

config := p.getConfiguration()
if err := config.IsValid(); err != nil {
return err
Expand All @@ -77,7 +82,7 @@ func (p *Plugin) OnActivate() error {
return errors.Wrap(err, "failed to register command")
}

botUserID, err := p.Helpers.EnsureBot(&model.Bot{
botUserID, err := p.client.Bot.EnsureBot(&model.Bot{
Username: botUserName,
DisplayName: botDisplayName,
Description: botDescription,
Expand Down
8 changes: 4 additions & 4 deletions server/plugin_test.go
Expand Up @@ -13,10 +13,10 @@ import (
"testing"

"github.com/mattermost/mattermost-plugin-api/experimental/telemetry"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest/mock"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest/mock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion server/store.go
Expand Up @@ -7,7 +7,7 @@ import (
"encoding/json"
"fmt"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
"golang.org/x/oauth2"

Expand Down
2 changes: 1 addition & 1 deletion server/zoom/client.go
Expand Up @@ -6,7 +6,7 @@ package zoom
import (
"encoding/json"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
"golang.org/x/oauth2"
)
Expand Down
2 changes: 1 addition & 1 deletion server/zoom/jwt.go
Expand Up @@ -10,7 +10,7 @@ import (
"net/http"

jwt "github.com/dgrijalva/jwt-go"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion server/zoom/oauth.go
Expand Up @@ -12,7 +12,7 @@ import (
"net/http"
"time"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
"golang.org/x/oauth2"
)
Expand Down

0 comments on commit ac7bf69

Please sign in to comment.