summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/platform/model/gitlab
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/mattermost/platform/model/gitlab
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/gitlab')
-rw-r--r--vendor/github.com/mattermost/platform/model/gitlab/gitlab.go114
1 files changed, 0 insertions, 114 deletions
diff --git a/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go b/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
deleted file mode 100644
index 7e0cb10a..00000000
--- a/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package oauthgitlab
-
-import (
- "encoding/json"
- "io"
- "strconv"
- "strings"
-
- "github.com/mattermost/mattermost-server/einterfaces"
- "github.com/mattermost/mattermost-server/model"
-)
-
-type GitLabProvider struct {
-}
-
-type GitLabUser struct {
- Id int64 `json:"id"`
- Username string `json:"username"`
- Login string `json:"login"`
- Email string `json:"email"`
- Name string `json:"name"`
-}
-
-func init() {
- provider := &GitLabProvider{}
- einterfaces.RegisterOauthProvider(model.USER_AUTH_SERVICE_GITLAB, provider)
-}
-
-func userFromGitLabUser(glu *GitLabUser) *model.User {
- user := &model.User{}
- username := glu.Username
- if username == "" {
- username = glu.Login
- }
- user.Username = model.CleanUsername(username)
- splitName := strings.Split(glu.Name, " ")
- if len(splitName) == 2 {
- user.FirstName = splitName[0]
- user.LastName = splitName[1]
- } else if len(splitName) >= 2 {
- user.FirstName = splitName[0]
- user.LastName = strings.Join(splitName[1:], " ")
- } else {
- user.FirstName = glu.Name
- }
- user.Email = glu.Email
- userId := strconv.FormatInt(glu.Id, 10)
- user.AuthData = &userId
- user.AuthService = model.USER_AUTH_SERVICE_GITLAB
-
- return user
-}
-
-func gitLabUserFromJson(data io.Reader) *GitLabUser {
- decoder := json.NewDecoder(data)
- var glu GitLabUser
- err := decoder.Decode(&glu)
- if err == nil {
- return &glu
- } else {
- return nil
- }
-}
-
-func (glu *GitLabUser) ToJson() string {
- b, err := json.Marshal(glu)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (glu *GitLabUser) IsValid() bool {
- if glu.Id == 0 {
- return false
- }
-
- if len(glu.Email) == 0 {
- return false
- }
-
- return true
-}
-
-func (glu *GitLabUser) getAuthData() string {
- return strconv.FormatInt(glu.Id, 10)
-}
-
-func (m *GitLabProvider) GetIdentifier() string {
- return model.USER_AUTH_SERVICE_GITLAB
-}
-
-func (m *GitLabProvider) GetUserFromJson(data io.Reader) *model.User {
- glu := gitLabUserFromJson(data)
- if glu.IsValid() {
- return userFromGitLabUser(glu)
- }
-
- return &model.User{}
-}
-
-func (m *GitLabProvider) GetAuthDataFromJson(data io.Reader) string {
- glu := gitLabUserFromJson(data)
-
- if glu.IsValid() {
- return glu.getAuthData()
- }
-
- return ""
-}