]> Sergey Matveev's repositories - mmfileget.git/commitdiff
New mattermost's model API
authorSergey Matveev <stargrave@stargrave.org>
Wed, 17 Nov 2021 09:13:59 +0000 (12:13 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 17 Nov 2021 09:13:59 +0000 (12:13 +0300)
go.mod
main.go
vendor-done.do

diff --git a/go.mod b/go.mod
index a4969e0fef1e350c69620b52a30be7a5b9f9f1e1..a5255d325f3168f11ae66c3576e65629ad82525c 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
 module go.stargrave.org/mmfileget
 
-go 1.15
+go 1.16
 
-require github.com/mattermost/mattermost-server/v5 v5.39.1
+require github.com/mattermost/mattermost-server/v6 v6.1.0
 
-replace github.com/mattermost/mattermost-server/v5 v5.39.1 => ./mattermost-server
+replace github.com/mattermost/mattermost-server/v6 v6.1.0 => ./mattermost-server
diff --git a/main.go b/main.go
index 38d2cb08d6434900b790d370a1856a106880fd78..a31bb51f758acc5abd77f058c0ee46ed9d8ca35c 100644 (file)
--- a/main.go
+++ b/main.go
@@ -3,10 +3,11 @@ package main
 import (
        "fmt"
        "io/ioutil"
+       "log"
        "os"
        "strings"
 
-       "github.com/mattermost/mattermost-server/v5/model"
+       "github.com/mattermost/mattermost-server/v6/model"
 )
 
 func main() {
@@ -20,9 +21,15 @@ func main() {
                os.Exit(1)
        }
 
-       Client := model.NewAPIv4Client("https://" + machine)
-       Client.Login(login, password)
-       info, resp := Client.GetFileInfo(fileId)
+       client := model.NewAPIv4Client("https://" + machine)
+       _, _, err := client.Login(login, password)
+       if err != nil {
+               log.Fatalln(err)
+       }
+       info, resp, err := client.GetFileInfo(fileId)
+       if err != nil {
+               log.Fatalln(err)
+       }
        if info == nil {
                fmt.Fprintln(os.Stderr, resp)
                os.Exit(1)
@@ -37,7 +44,10 @@ func main() {
                fmt.Fprintln(os.Stderr, "Download? Ctrl-D/C")
                os.Stdin.Read(make([]byte, 1))
        }
-       data, _ := Client.GetFile(fileId)
+       data, _, err := client.GetFile(fileId)
+       if err != nil {
+               log.Fatalln(err)
+       }
        if err := ioutil.WriteFile(filename, data, os.FileMode(0666)); err != nil {
                panic(err)
        }
index 9ec502719edbf3a2fa728854869ed942992dac9e..b5f38eba2ae41c0385b823c58a848c664652856c 100644 (file)
@@ -1,10 +1,10 @@
-git clone --depth 1 --branch v5.29.0 https://github.com/mattermost/mattermost-server.git
+git clone --depth 1 --branch v6.1.0 https://github.com/mattermost/mattermost-server.git
 ln -fs mattermost-server/vendor .
 mkdir -p vendor/github.com/mattermost/mattermost-server
-ln -fs `pwd`/mattermost-server vendor/github.com/mattermost/mattermost-server/v5
+ln -fs `pwd`/mattermost-server vendor/github.com/mattermost/mattermost-server/v6
 cat > vendor/modules.txt <<EOF
-# github.com/mattermost/mattermost-server/v5 v5.39.1 => ./mattermost-server
+# github.com/mattermost/mattermost-server/v6 v6.1.0 => ./mattermost-server
 ## explicit
-github.com/mattermost/mattermost-server/v5
+github.com/mattermost/mattermost-server/v6
 EOF
 touch $3