From 33844fa60c5b432c4b6a4fb966be6e8f04627165 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 21 May 2016 14:14:08 +0200 Subject: Commit mattermost vendoring --- .../mattermost/platform/einterfaces/brand.go | 24 ++++ .../mattermost/platform/einterfaces/compliance.go | 23 ++++ .../mattermost/platform/einterfaces/mfa.go | 25 ++++ .../mattermost/platform/model/compliance.go | 132 +++++++++++++++++++++ .../mattermost/platform/model/compliance_post.go | 104 ++++++++++++++++ .../github.com/mattermost/platform/model/gitlab.go | 8 ++ .../mattermost/platform/model/initial_load.go | 40 +++++++ .../github.com/mattermost/platform/model/ldap.go | 8 ++ .../mattermost/platform/model/password_recovery.go | 37 ++++++ .../mattermost/platform/model/team_member.go | 120 +++++++++++++++++++ 10 files changed, 521 insertions(+) create mode 100644 vendor/github.com/mattermost/platform/einterfaces/brand.go create mode 100644 vendor/github.com/mattermost/platform/einterfaces/compliance.go create mode 100644 vendor/github.com/mattermost/platform/einterfaces/mfa.go create mode 100644 vendor/github.com/mattermost/platform/model/compliance.go create mode 100644 vendor/github.com/mattermost/platform/model/compliance_post.go create mode 100644 vendor/github.com/mattermost/platform/model/gitlab.go create mode 100644 vendor/github.com/mattermost/platform/model/initial_load.go create mode 100644 vendor/github.com/mattermost/platform/model/ldap.go create mode 100644 vendor/github.com/mattermost/platform/model/password_recovery.go create mode 100644 vendor/github.com/mattermost/platform/model/team_member.go (limited to 'vendor') diff --git a/vendor/github.com/mattermost/platform/einterfaces/brand.go b/vendor/github.com/mattermost/platform/einterfaces/brand.go new file mode 100644 index 00000000..7c15659b --- /dev/null +++ b/vendor/github.com/mattermost/platform/einterfaces/brand.go @@ -0,0 +1,24 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package einterfaces + +import ( + "github.com/mattermost/platform/model" + "mime/multipart" +) + +type BrandInterface interface { + SaveBrandImage(*multipart.FileHeader) *model.AppError + GetBrandImage() ([]byte, *model.AppError) +} + +var theBrandInterface BrandInterface + +func RegisterBrandInterface(newInterface BrandInterface) { + theBrandInterface = newInterface +} + +func GetBrandInterface() BrandInterface { + return theBrandInterface +} diff --git a/vendor/github.com/mattermost/platform/einterfaces/compliance.go b/vendor/github.com/mattermost/platform/einterfaces/compliance.go new file mode 100644 index 00000000..2e72c67d --- /dev/null +++ b/vendor/github.com/mattermost/platform/einterfaces/compliance.go @@ -0,0 +1,23 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package einterfaces + +import ( + "github.com/mattermost/platform/model" +) + +type ComplianceInterface interface { + StartComplianceDailyJob() + RunComplianceJob(job *model.Compliance) *model.AppError +} + +var theComplianceInterface ComplianceInterface + +func RegisterComplianceInterface(newInterface ComplianceInterface) { + theComplianceInterface = newInterface +} + +func GetComplianceInterface() ComplianceInterface { + return theComplianceInterface +} diff --git a/vendor/github.com/mattermost/platform/einterfaces/mfa.go b/vendor/github.com/mattermost/platform/einterfaces/mfa.go new file mode 100644 index 00000000..25f3ed91 --- /dev/null +++ b/vendor/github.com/mattermost/platform/einterfaces/mfa.go @@ -0,0 +1,25 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package einterfaces + +import ( + "github.com/mattermost/platform/model" +) + +type MfaInterface interface { + GenerateQrCode(user *model.User) ([]byte, *model.AppError) + Activate(user *model.User, token string) *model.AppError + Deactivate(userId string) *model.AppError + ValidateToken(secret, token string) (bool, *model.AppError) +} + +var theMfaInterface MfaInterface + +func RegisterMfaInterface(newInterface MfaInterface) { + theMfaInterface = newInterface +} + +func GetMfaInterface() MfaInterface { + return theMfaInterface +} diff --git a/vendor/github.com/mattermost/platform/model/compliance.go b/vendor/github.com/mattermost/platform/model/compliance.go new file mode 100644 index 00000000..4a96a597 --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/compliance.go @@ -0,0 +1,132 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" + "strings" +) + +const ( + COMPLIANCE_STATUS_CREATED = "created" + COMPLIANCE_STATUS_RUNNING = "running" + COMPLIANCE_STATUS_FINISHED = "finished" + COMPLIANCE_STATUS_FAILED = "failed" + COMPLIANCE_STATUS_REMOVED = "removed" + + COMPLIANCE_TYPE_DAILY = "daily" + COMPLIANCE_TYPE_ADHOC = "adhoc" +) + +type Compliance struct { + Id string `json:"id"` + CreateAt int64 `json:"create_at"` + UserId string `json:"user_id"` + Status string `json:"status"` + Count int `json:"count"` + Desc string `json:"desc"` + Type string `json:"type"` + StartAt int64 `json:"start_at"` + EndAt int64 `json:"end_at"` + Keywords string `json:"keywords"` + Emails string `json:"emails"` +} + +type Compliances []Compliance + +func (o *Compliance) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func (me *Compliance) PreSave() { + if me.Id == "" { + me.Id = NewId() + } + + if me.Status == "" { + me.Status = COMPLIANCE_STATUS_CREATED + } + + me.Count = 0 + me.Emails = strings.ToLower(me.Emails) + me.Keywords = strings.ToLower(me.Keywords) + + me.CreateAt = GetMillis() +} + +func (me *Compliance) JobName() string { + jobName := me.Type + if me.Type == COMPLIANCE_TYPE_DAILY { + jobName += "-" + me.Desc + } + + jobName += "-" + me.Id + + return jobName +} + +func (me *Compliance) IsValid() *AppError { + + if len(me.Id) != 26 { + return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.id.app_error", nil, "") + } + + if me.CreateAt == 0 { + return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.create_at.app_error", nil, "") + } + + if len(me.Desc) > 512 || len(me.Desc) == 0 { + return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.desc.app_error", nil, "") + } + + if me.StartAt == 0 { + return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.start_at.app_error", nil, "") + } + + if me.EndAt == 0 { + return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.end_at.app_error", nil, "") + } + + if me.EndAt <= me.StartAt { + return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.start_end_at.app_error", nil, "") + } + + return nil +} + +func ComplianceFromJson(data io.Reader) *Compliance { + decoder := json.NewDecoder(data) + var o Compliance + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} + +func (o Compliances) ToJson() string { + if b, err := json.Marshal(o); err != nil { + return "[]" + } else { + return string(b) + } +} + +func CompliancesFromJson(data io.Reader) Compliances { + decoder := json.NewDecoder(data) + var o Compliances + err := decoder.Decode(&o) + if err == nil { + return o + } else { + return nil + } +} diff --git a/vendor/github.com/mattermost/platform/model/compliance_post.go b/vendor/github.com/mattermost/platform/model/compliance_post.go new file mode 100644 index 00000000..ce26a366 --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/compliance_post.go @@ -0,0 +1,104 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "time" +) + +type CompliancePost struct { + + // From Team + TeamName string + TeamDisplayName string + + // From Channel + ChannelName string + ChannelDisplayName string + + // From User + UserUsername string + UserEmail string + UserNickname string + + // From Post + PostId string + PostCreateAt int64 + PostUpdateAt int64 + PostDeleteAt int64 + PostRootId string + PostParentId string + PostOriginalId string + PostMessage string + PostType string + PostProps string + PostHashtags string + PostFilenames string +} + +func CompliancePostHeader() []string { + return []string{ + "TeamName", + "TeamDisplayName", + + "ChannelName", + "ChannelDisplayName", + + "UserUsername", + "UserEmail", + "UserNickname", + + "PostId", + "PostCreateAt", + "PostUpdateAt", + "PostDeleteAt", + "PostRootId", + "PostParentId", + "PostOriginalId", + "PostMessage", + "PostType", + "PostProps", + "PostHashtags", + "PostFilenames", + } +} + +func (me *CompliancePost) Row() []string { + + postDeleteAt := "" + if me.PostDeleteAt > 0 { + postDeleteAt = time.Unix(0, me.PostDeleteAt*int64(1000*1000)).Format(time.RFC3339) + } + + postUpdateAt := "" + if me.PostUpdateAt != me.PostCreateAt { + postUpdateAt = time.Unix(0, me.PostUpdateAt*int64(1000*1000)).Format(time.RFC3339) + } + + return []string{ + me.TeamName, + me.TeamDisplayName, + + me.ChannelName, + me.ChannelDisplayName, + + me.UserUsername, + me.UserEmail, + me.UserNickname, + + me.PostId, + time.Unix(0, me.PostCreateAt*int64(1000*1000)).Format(time.RFC3339), + postUpdateAt, + postDeleteAt, + + me.PostRootId, + me.PostParentId, + me.PostOriginalId, + me.PostMessage, + me.PostType, + me.PostProps, + me.PostHashtags, + me.PostFilenames, + } +} diff --git a/vendor/github.com/mattermost/platform/model/gitlab.go b/vendor/github.com/mattermost/platform/model/gitlab.go new file mode 100644 index 00000000..3dfb1016 --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/gitlab.go @@ -0,0 +1,8 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +const ( + USER_AUTH_SERVICE_GITLAB = "gitlab" +) diff --git a/vendor/github.com/mattermost/platform/model/initial_load.go b/vendor/github.com/mattermost/platform/model/initial_load.go new file mode 100644 index 00000000..d7587e6d --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/initial_load.go @@ -0,0 +1,40 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" +) + +type InitialLoad struct { + User *User `json:"user"` + TeamMembers []*TeamMember `json:"team_members"` + Teams []*Team `json:"teams"` + DirectProfiles map[string]*User `json:"direct_profiles"` + Preferences Preferences `json:"preferences"` + ClientCfg map[string]string `json:"client_cfg"` + LicenseCfg map[string]string `json:"license_cfg"` + NoAccounts bool `json:"no_accounts"` +} + +func (me *InitialLoad) ToJson() string { + b, err := json.Marshal(me) + if err != nil { + return "" + } else { + return string(b) + } +} + +func InitialLoadFromJson(data io.Reader) *InitialLoad { + decoder := json.NewDecoder(data) + var o InitialLoad + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} diff --git a/vendor/github.com/mattermost/platform/model/ldap.go b/vendor/github.com/mattermost/platform/model/ldap.go new file mode 100644 index 00000000..5fde06a6 --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/ldap.go @@ -0,0 +1,8 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +const ( + USER_AUTH_SERVICE_LDAP = "ldap" +) diff --git a/vendor/github.com/mattermost/platform/model/password_recovery.go b/vendor/github.com/mattermost/platform/model/password_recovery.go new file mode 100644 index 00000000..303d4a12 --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/password_recovery.go @@ -0,0 +1,37 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +const ( + PASSWORD_RECOVERY_CODE_SIZE = 128 + PASSWORD_RECOVER_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour +) + +type PasswordRecovery struct { + UserId string + Code string + CreateAt int64 +} + +func (p *PasswordRecovery) IsValid() *AppError { + + if len(p.UserId) != 26 { + return NewLocAppError("User.IsValid", "model.password_recovery.is_valid.user_id.app_error", nil, "") + } + + if len(p.Code) != PASSWORD_RECOVERY_CODE_SIZE { + return NewLocAppError("User.IsValid", "model.password_recovery.is_valid.code.app_error", nil, "") + } + + if p.CreateAt == 0 { + return NewLocAppError("User.IsValid", "model.password_recovery.is_valid.create_at.app_error", nil, "") + } + + return nil +} + +func (p *PasswordRecovery) PreSave() { + p.Code = NewRandomString(PASSWORD_RECOVERY_CODE_SIZE) + p.CreateAt = GetMillis() +} diff --git a/vendor/github.com/mattermost/platform/model/team_member.go b/vendor/github.com/mattermost/platform/model/team_member.go new file mode 100644 index 00000000..ae687c10 --- /dev/null +++ b/vendor/github.com/mattermost/platform/model/team_member.go @@ -0,0 +1,120 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" + "strings" +) + +const ( + ROLE_TEAM_ADMIN = "admin" +) + +type TeamMember struct { + TeamId string `json:"team_id"` + UserId string `json:"user_id"` + Roles string `json:"roles"` +} + +func (o *TeamMember) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func TeamMemberFromJson(data io.Reader) *TeamMember { + decoder := json.NewDecoder(data) + var o TeamMember + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} + +func TeamMembersToJson(o []*TeamMember) string { + if b, err := json.Marshal(o); err != nil { + return "[]" + } else { + return string(b) + } +} + +func TeamMembersFromJson(data io.Reader) []*TeamMember { + decoder := json.NewDecoder(data) + var o []*TeamMember + err := decoder.Decode(&o) + if err == nil { + return o + } else { + return nil + } +} + +func IsValidTeamRoles(teamRoles string) bool { + + roles := strings.Split(teamRoles, " ") + + for _, r := range roles { + if !isValidTeamRole(r) { + return false + } + } + + return true +} + +func isValidTeamRole(role string) bool { + if role == "" { + return true + } + + if role == ROLE_TEAM_ADMIN { + return true + } + + return false +} + +func IsInTeamRole(teamRoles string, inRole string) bool { + roles := strings.Split(teamRoles, " ") + + for _, r := range roles { + if r == inRole { + return true + } + + } + + return false +} + +func (o *TeamMember) IsTeamAdmin() bool { + return IsInTeamRole(o.Roles, ROLE_TEAM_ADMIN) +} + +func (o *TeamMember) IsValid() *AppError { + + if len(o.TeamId) != 26 { + return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.team_id.app_error", nil, "") + } + + if len(o.UserId) != 26 { + return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.user_id.app_error", nil, "") + } + + for _, role := range strings.Split(o.Roles, " ") { + if !(role == "" || role == ROLE_TEAM_ADMIN) { + return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.role.app_error", nil, "role="+role) + } + } + + return nil +} -- cgit v1.2.3