4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-11 03:02:30 +00:00

Sync with mattermost 3.0

This commit is contained in:
Wim
2016-05-15 23:02:30 +02:00
parent 38e3bbe5c9
commit 59e6abcc11
22 changed files with 850 additions and 242 deletions

View File

@@ -9,7 +9,7 @@ import (
)
const (
SESSION_COOKIE_TOKEN = "MMTOKEN"
SESSION_COOKIE_TOKEN = "MMAUTHTOKEN"
SESSION_CACHE_SIZE = 10000
SESSION_PROP_PLATFORM = "platform"
SESSION_PROP_OS = "os"
@@ -17,17 +17,17 @@ const (
)
type Session struct {
Id string `json:"id"`
Token string `json:"token"`
CreateAt int64 `json:"create_at"`
ExpiresAt int64 `json:"expires_at"`
LastActivityAt int64 `json:"last_activity_at"`
UserId string `json:"user_id"`
TeamId string `json:"team_id"`
DeviceId string `json:"device_id"`
Roles string `json:"roles"`
IsOAuth bool `json:"is_oauth"`
Props StringMap `json:"props"`
Id string `json:"id"`
Token string `json:"token"`
CreateAt int64 `json:"create_at"`
ExpiresAt int64 `json:"expires_at"`
LastActivityAt int64 `json:"last_activity_at"`
UserId string `json:"user_id"`
DeviceId string `json:"device_id"`
Roles string `json:"roles"`
IsOAuth bool `json:"is_oauth"`
Props StringMap `json:"props"`
TeamMembers []*TeamMember `json:"team_members" db:"-"`
}
func (me *Session) ToJson() string {
@@ -95,6 +95,16 @@ func (me *Session) AddProp(key string, value string) {
me.Props[key] = value
}
func (me *Session) GetTeamByTeamId(teamId string) *TeamMember {
for _, team := range me.TeamMembers {
if team.TeamId == teamId {
return team
}
}
return nil
}
func SessionsToJson(o []*Session) string {
if b, err := json.Marshal(o); err != nil {
return "[]"