Commit cd55c44c authored by George Goldberg's avatar George Goldberg Committed by Martin Kraft

MM-8796: Full implementation of "Schemes" in Store/Model/App layers. (#8357)

* Add Scheme model and stub store.

* Port ChannelStore to be Scheme aware.

* Make almost all the API/APP layer work with ChannelSchemes.

Only thing still hacky is UpdateChannelMemberRoles().

* Add basic SchemeStore implementation.

* Migrate UpdateChannelMemberRoles properly and fix tests.

* Update store tests and mocks so they work.

* Include creating default roles in Scheme create store function.

* Implement role deletion and start scheme deletion.

* Only use non-deleted roles for authorization.

* Add GetByScheme method to Team store.

* Add GetChannelsByScheme.

* Update store mocks.

* Implement scheme deletion in the store.

* Rename is valid function.

* Add offset and limit to queries to fetch teams and channels by scheme.

* Fix queries.

* Implement scheme awareness in Team store and add a migration.

* Tidy up ChannelStore mapping functions and add exhaustive unit tests.

* Add all missing i18n.

* Proper tests for TeamStore internal functions and fix them.

* Make additional TeamMember fields nullable.

* Make new ChannelMember fields nullable.

* Create new nullable columns without defaults.

* Make new fields in large tables nullalble.

* Fix empty list of TeamMembers.

* Deduplicate SQL queries.

* Fix spelling.

* Fix review comment.

* More review fixes.

* More review fixes.
parent 853445dc
......@@ -245,28 +245,36 @@ func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
func (me *TestHelper) UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.TEAM_USER_ROLE_ID + " " + model.TEAM_ADMIN_ROLE_ID}
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
if tmr := <-me.App.Srv.Store.Team().GetMember(team.Id, user.Id); tmr.Err == nil {
tm := tmr.Data.(*model.TeamMember)
tm.SchemeAdmin = true
if sr := <-me.App.Srv.Store.Team().UpdateMember(tm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
}
} else {
utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error())
l4g.Close()
time.Sleep(time.Second)
panic(tmr.Err)
}
utils.EnableDebugLogForTest()
}
func (me *TestHelper) UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.TEAM_USER_ROLE_ID}
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
if tmr := <-me.App.Srv.Store.Team().GetMember(team.Id, user.Id); tmr.Err == nil {
tm := tmr.Data.(*model.TeamMember)
tm.SchemeAdmin = false
if sr := <-me.App.Srv.Store.Team().UpdateMember(tm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
}
} else {
utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error())
l4g.Close()
time.Sleep(time.Second)
panic(tmr.Err)
}
utils.EnableDebugLogForTest()
}
......@@ -275,7 +283,7 @@ func (me *TestHelper) MakeUserChannelAdmin(user *model.User, channel *model.Chan
if cmr := <-me.App.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_admin channel_user"
cm.SchemeAdmin = true
if sr := <-me.App.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
......@@ -293,7 +301,7 @@ func (me *TestHelper) MakeUserChannelUser(user *model.User, channel *model.Chann
if cmr := <-me.App.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_user"
cm.SchemeAdmin = false
if sr := <-me.App.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
......
......@@ -765,7 +765,7 @@ func (me *TestHelper) MakeUserChannelAdmin(user *model.User, channel *model.Chan
if cmr := <-me.App.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_admin channel_user"
cm.SchemeAdmin = true
if sr := <-me.App.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
......@@ -781,28 +781,36 @@ func (me *TestHelper) MakeUserChannelAdmin(user *model.User, channel *model.Chan
func (me *TestHelper) UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.TEAM_USER_ROLE_ID + " " + model.TEAM_ADMIN_ROLE_ID}
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
if tmr := <-me.App.Srv.Store.Team().GetMember(team.Id, user.Id); tmr.Err == nil {
tm := tmr.Data.(*model.TeamMember)
tm.SchemeAdmin = true
if sr := <-me.App.Srv.Store.Team().UpdateMember(tm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
}
} else {
utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error())
l4g.Close()
time.Sleep(time.Second)
panic(tmr.Err)
}
utils.EnableDebugLogForTest()
}
func (me *TestHelper) UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.TEAM_USER_ROLE_ID}
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
if tmr := <-me.App.Srv.Store.Team().GetMember(team.Id, user.Id); tmr.Err == nil {
tm := tmr.Data.(*model.TeamMember)
tm.SchemeAdmin = false
if sr := <-me.App.Srv.Store.Team().UpdateMember(tm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
}
} else {
utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error())
l4g.Close()
time.Sleep(time.Second)
panic(tmr.Err)
}
utils.EnableDebugLogForTest()
}
......
......@@ -1388,7 +1388,7 @@ func TestUpdateChannelRoles(t *testing.T) {
defer th.TearDown()
Client := th.Client
const CHANNEL_ADMIN = "channel_admin channel_user"
const CHANNEL_ADMIN = "channel_user channel_admin"
const CHANNEL_MEMBER = "channel_user"
// User 1 creates a channel, making them channel admin by default.
......
......@@ -1672,7 +1672,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
// user 1 (team admin) tries to demote system admin (not member of a team)
_, resp = Client.UpdateTeamMemberRoles(th.BasicTeam.Id, th.SystemAdminUser.Id, TEAM_MEMBER)
CheckBadRequestStatus(t, resp)
CheckNotFoundStatus(t, resp)
// user 1 (team admin) demotes system admin (member of a team)
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
......@@ -1698,7 +1698,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
// user 1 (team admin) tries to promote a random user
_, resp = Client.UpdateTeamMemberRoles(th.BasicTeam.Id, model.NewId(), TEAM_ADMIN)
CheckBadRequestStatus(t, resp)
CheckNotFoundStatus(t, resp)
// user 1 (team admin) tries to promote invalid team permission
_, resp = Client.UpdateTeamMemberRoles(th.BasicTeam.Id, th.BasicUser.Id, "junk")
......
......@@ -199,6 +199,10 @@ func (a *App) RolesGrantPermission(roleNames []string, permissionId string) bool
}
for _, role := range roles {
if role.DeleteAt != 0 {
continue
}
permissions := role.Permissions
for _, permission := range permissions {
if permission == permissionId {
......
......@@ -32,7 +32,7 @@ func (a *App) CreateDefaultChannels(teamId string) ([]*model.Channel, *model.App
return channels, nil
}
func (a *App) JoinDefaultChannels(teamId string, user *model.User, channelRole string, userRequestorId string) *model.AppError {
func (a *App) JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin bool, userRequestorId string) *model.AppError {
var err *model.AppError = nil
var requestor *model.User
......@@ -52,7 +52,8 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, channelRole s
cm := &model.ChannelMember{
ChannelId: townSquare.Id,
UserId: user.Id,
Roles: channelRole,
SchemeUser: true,
SchemeAdmin: shouldBeAdmin,
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
......@@ -85,7 +86,8 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, channelRole s
cm := &model.ChannelMember{
ChannelId: offTopic.Id,
UserId: user.Id,
Roles: channelRole,
SchemeUser: true,
SchemeAdmin: shouldBeAdmin,
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
......@@ -166,7 +168,8 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
cm := &model.ChannelMember{
ChannelId: sc.Id,
UserId: channel.CreatorId,
Roles: model.CHANNEL_USER_ROLE_ID + " " + model.CHANNEL_ADMIN_ROLE_ID,
SchemeUser: true,
SchemeAdmin: true,
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
......@@ -322,7 +325,7 @@ func (a *App) createGroupChannel(userIds []string, creatorId string) (*model.Cha
UserId: user.Id,
ChannelId: group.Id,
NotifyProps: model.GetDefaultChannelNotifyProps(),
Roles: model.CHANNEL_USER_ROLE_ID,
SchemeUser: true,
}
if result := <-a.Srv.Store.Channel().SaveMember(cm); result.Err != nil {
......@@ -432,6 +435,39 @@ func (a *App) PatchChannel(channel *model.Channel, patch *model.ChannelPatch, us
return channel, err
}
func (a *App) GetSchemeRolesForChannel(channelId string) (string, string, *model.AppError) {
var channel *model.Channel
var err *model.AppError
if channel, err = a.GetChannel(channelId); err != nil {
return "", "", err
}
if channel.SchemeId != nil && len(*channel.SchemeId) != 0 {
if scheme, err := a.GetScheme(*channel.SchemeId); err != nil {
return "", "", err
} else {
return scheme.DefaultChannelUserRole, scheme.DefaultChannelAdminRole, nil
}
}
var team *model.Team
if team, err = a.GetTeam(channel.TeamId); err != nil {
return "", "", err
}
if team.SchemeId != nil && len(*team.SchemeId) != 0 {
if scheme, err := a.GetScheme(*team.SchemeId); err != nil {
return "", "", err
} else {
return scheme.DefaultChannelUserRole, scheme.DefaultChannelAdminRole, nil
}
}
return model.CHANNEL_USER_ROLE_ID, model.CHANNEL_ADMIN_ROLE_ID, nil
}
func (a *App) UpdateChannelMemberRoles(channelId string, userId string, newRoles string) (*model.ChannelMember, *model.AppError) {
var member *model.ChannelMember
var err *model.AppError
......@@ -439,14 +475,42 @@ func (a *App) UpdateChannelMemberRoles(channelId string, userId string, newRoles
return nil, err
}
if err := a.CheckRolesExist(strings.Fields(newRoles)); err != nil {
schemeUserRole, schemeAdminRole, err := a.GetSchemeRolesForChannel(channelId)
if err != nil {
return nil, err
}
member.Roles = newRoles
var newExplicitRoles []string
member.SchemeUser = false
member.SchemeAdmin = false
for _, roleName := range strings.Fields(newRoles) {
if role, err := a.GetRoleByName(roleName); err != nil {
err.StatusCode = http.StatusBadRequest
return nil, err
} else if !role.SchemeManaged {
// The role is not scheme-managed, so it's OK to apply it to the explicit roles field.
newExplicitRoles = append(newExplicitRoles, roleName)
} else {
// The role is scheme-managed, so need to check if it is part of the scheme for this channel or not.
switch roleName {
case schemeAdminRole:
member.SchemeAdmin = true
case schemeUserRole:
member.SchemeUser = true
default:
// If not part of the scheme for this channel, then it is not allowed to apply it as an explicit role.
return nil, model.NewAppError("UpdateChannelMemberRoles", "api.channel.update_channel_member_roles.scheme_role.app_error", nil, "role_name="+roleName, http.StatusBadRequest)
}
}
}
member.ExplicitRoles = strings.Join(newExplicitRoles, " ")
if result := <-a.Srv.Store.Channel().UpdateMember(member); result.Err != nil {
return nil, result.Err
} else {
member = result.Data.(*model.ChannelMember)
}
a.InvalidateCacheForUser(userId)
......@@ -591,7 +655,7 @@ func (a *App) addUserToChannel(user *model.User, channel *model.Channel, teamMem
ChannelId: channel.Id,
UserId: user.Id,
NotifyProps: model.GetDefaultChannelNotifyProps(),
Roles: model.CHANNEL_USER_ROLE_ID,
SchemeUser: true,
}
if result := <-a.Srv.Store.Channel().SaveMember(newMember); result.Err != nil {
l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, result.Err)
......
......@@ -120,7 +120,7 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testi
// create a new user that joins the default channels
user := th.CreateUser()
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, model.CHANNEL_USER_ROLE_ID, "")
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, false, "")
// there should be a ChannelMemberHistory record for the user
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)).([]*model.ChannelMemberHistoryResult)
......@@ -146,7 +146,7 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordOffTopic(t *testing
// create a new user that joins the default channels
user := th.CreateUser()
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, model.CHANNEL_USER_ROLE_ID, "")
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, false, "")
// there should be a ChannelMemberHistory record for the user
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)).([]*model.ChannelMemberHistoryResult)
......
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import "github.com/mattermost/mattermost-server/model"
func (a *App) GetScheme(id string) (*model.Scheme, *model.AppError) {
if result := <-a.Srv.Store.Scheme().Get(id); result.Err != nil {
return nil, result.Err
} else {
return result.Data.(*model.Scheme), nil
}
}
......@@ -141,17 +141,31 @@ func (a *App) sendTeamEvent(team *model.Team, event string) {
a.Publish(message)
}
func (a *App) GetSchemeRolesForTeam(teamId string) (string, string, *model.AppError) {
var team *model.Team
var err *model.AppError
if team, err = a.GetTeam(teamId); err != nil {
return "", "", err
}
if team.SchemeId != nil && len(*team.SchemeId) != 0 {
if scheme, err := a.GetScheme(*team.SchemeId); err != nil {
return "", "", err
} else {
return scheme.DefaultTeamUserRole, scheme.DefaultTeamAdminRole, nil
}
}
return model.TEAM_USER_ROLE_ID, model.TEAM_ADMIN_ROLE_ID, nil
}
func (a *App) UpdateTeamMemberRoles(teamId string, userId string, newRoles string) (*model.TeamMember, *model.AppError) {
var member *model.TeamMember
if result := <-a.Srv.Store.Team().GetTeamsForUser(userId); result.Err != nil {
if result := <-a.Srv.Store.Team().GetMember(teamId, userId); result.Err != nil {
return nil, result.Err
} else {
members := result.Data.([]*model.TeamMember)
for _, m := range members {
if m.TeamId == teamId {
member = m
}
}
member = result.Data.(*model.TeamMember)
}
if member == nil {
......@@ -159,14 +173,42 @@ func (a *App) UpdateTeamMemberRoles(teamId string, userId string, newRoles strin
return nil, err
}
if err := a.CheckRolesExist(strings.Fields(newRoles)); err != nil {
schemeUserRole, schemeAdminRole, err := a.GetSchemeRolesForTeam(teamId)
if err != nil {
return nil, err
}
member.Roles = newRoles
var newExplicitRoles []string
member.SchemeUser = false
member.SchemeAdmin = false
for _, roleName := range strings.Fields(newRoles) {
if role, err := a.GetRoleByName(roleName); err != nil {
err.StatusCode = http.StatusBadRequest
return nil, err
} else if !role.SchemeManaged {
// The role is not scheme-managed, so it's OK to apply it to the explicit roles field.
newExplicitRoles = append(newExplicitRoles, roleName)
} else {
// The role is scheme-managed, so need to check if it is part of the scheme for this channel or not.
switch roleName {
case schemeAdminRole:
member.SchemeAdmin = true
case schemeUserRole:
member.SchemeUser = true
default:
// If not part of the scheme for this channel, then it is not allowed to apply it as an explicit role.
return nil, model.NewAppError("UpdateTeamMemberRoles", "api.channel.update_team_member_roles.scheme_role.app_error", nil, "role_name="+roleName, http.StatusBadRequest)
}
}
}
member.ExplicitRoles = strings.Join(newExplicitRoles, " ")
if result := <-a.Srv.Store.Team().UpdateMember(member); result.Err != nil {
return nil, result.Err
} else {
member = result.Data.(*model.TeamMember)
}
a.ClearSessionCacheForUser(userId)
......@@ -292,13 +334,13 @@ func (a *App) AddUserToTeamByInviteId(inviteId string, userId string) (*model.Te
// 3. a pointer to an AppError if something went wrong.
func (a *App) joinUserToTeam(team *model.Team, user *model.User) (*model.TeamMember, bool, *model.AppError) {
tm := &model.TeamMember{
TeamId: team.Id,
UserId: user.Id,
Roles: model.TEAM_USER_ROLE_ID,
TeamId: team.Id,
UserId: user.Id,
SchemeUser: true,
}
if team.Email == user.Email {
tm.Roles = model.TEAM_USER_ROLE_ID + " " + model.TEAM_ADMIN_ROLE_ID
tm.SchemeAdmin = true
}
if etmr := <-a.Srv.Store.Team().GetMember(team.Id, user.Id); etmr.Err == nil {
......@@ -342,14 +384,10 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
return uua.Err
}
channelRole := model.CHANNEL_USER_ROLE_ID
if team.Email == user.Email {
channelRole = model.CHANNEL_USER_ROLE_ID + " " + model.CHANNEL_ADMIN_ROLE_ID
}
shouldBeAdmin := team.Email == user.Email
// Soft error if there is an issue joining the default channels
if err := a.JoinDefaultChannels(team.Id, user, channelRole, userRequestorId); err != nil {
if err := a.JoinDefaultChannels(team.Id, user, shouldBeAdmin, userRequestorId); err != nil {
l4g.Error(utils.T("api.user.create_user.joining.error"), user.Id, team.Id, err)
}
......
......@@ -6690,6 +6690,86 @@
"id": "store.sql_role.get_by_name.app_error",
"translation": "Unable to get role"
},
{
"id": "api.channel.update_channel_member_roles.scheme_role.app_error",
"translation": "The provided role is managed by a Scheme and therefore cannot be applied directly to a Channel Member"
},
{
"id": "api.channel.update_team_member_roles.scheme_role.app_error",
"translation": "The provided role is managed by a Scheme and therefore cannot be applied directly to a Team Member"
},
{
"id": "store.sql_channel.get_by_scheme.app_error",
"translation": "Unable to get the channels for the provided scheme"
},
{
"id": "store.sql_team.get_by_scheme.app_error",
"translation": "Unable to get the channels for the provided scheme"
},
{
"id": "store.sql_role.save.open_transaction.app_error",
"translation": "Failed to open the transaction to save the role"
},
{
"id": "store.sql_role.save_role.commit_transaction.app_error",
"translation": "Failed to commit the transaction to save the role"
},
{
"id": "store.sql_role.save.invalid_role.app_error",
"translation": "The provided role is invalid"
},
{
"id": "store.sql_role.delete.update.app_error",
"translation": "Unable to delete the role"
},
{
"id": "store.sql_scheme.save.open_transaction.app_error",
"translation": "Failed to open the transaction to save the scheme"
},
{
"id": "store.sql_scheme.save_scheme.commit_transaction.app_error",
"translation": "Failed to commit the transaction to save the scheme"
},
{
"id": "store.sql_scheme.save.invalid_scheme.app_error",
"translation": "The provided scheme is invalid"
},
{
"id": "store.sql_scheme.save.update.app_error",
"translation": "Unable to update the scheme"
},
{
"id": "store.sql_scheme.save.retrieve_default_scheme_roles.app_error",
"translation": "Unable to retrieve the default scheme roles"
},
{
"id": "store.sql_scheme.save.insert.app_error",
"translation": "Unable to create the scheme"
},
{
"id": "store.sql_scheme.get.app_error",
"translation": "Unable to get the scheme"
},
{
"id": "store.sql_scheme.team_count.app_error",
"translation": "Unable to count the number of teams using this scheme"
},
{
"id": "store.sql_scheme.delete.scheme_in_use.app_error",
"translation": "Unable to delete the scheme as it in use by 1 or more teams or channels"
},
{
"id": "store.sql_scheme.channel_count.app_error",
"translation": "Unable to count the number of channels using this scheme"
},
{
"id": "store.sql_scheme.delete.role_update.app_error",
"translation": "Unable to delete the roles belonging to this scheme"
},
{
"id": "store.sql_scheme.delete.update.app_error",
"translation": "Unable to delete the scheme"
},
{
"id": "store.sql_role.get_by_names.app_error",
"translation": "Unable to get roles"
......
......@@ -32,20 +32,21 @@ const (
)
type Channel struct {
Id string `json:"id"`
CreateAt int64 `json:"create_at"`
UpdateAt int64 `json:"update_at"`
DeleteAt int64 `json:"delete_at"`
TeamId string `json:"team_id"`
Type string `json:"type"`
DisplayName string `json:"display_name"`
Name string `json:"name"`
Header string `json:"header"`
Purpose string `json:"purpose"`
LastPostAt int64 `json:"last_post_at"`
TotalMsgCount int64 `json:"total_msg_count"`
ExtraUpdateAt int64 `json:"extra_update_at"`
CreatorId string `json:"creator_id"`
Id string `json:"id"`
CreateAt int64 `json:"create_at"`
UpdateAt int64 `json:"update_at"`
DeleteAt int64 `json:"delete_at"`
TeamId string `json:"team_id"`
Type string `json:"type"`
DisplayName string `json:"display_name"`
Name string `json:"name"`
Header string `json:"header"`
Purpose string `json:"purpose"`
LastPostAt int64 `json:"last_post_at"`
TotalMsgCount int64 `json:"total_msg_count"`
ExtraUpdateAt int64 `json:"extra_update_at"`
CreatorId string `json:"creator_id"`
SchemeId *string `json:"scheme_id"`
}
type ChannelPatch struct {
......
......@@ -28,14 +28,17 @@ type ChannelUnread struct {
}
type ChannelMember struct {
ChannelId string `json:"channel_id"`
UserId string `json:"user_id"`
Roles string `json:"roles"`
LastViewedAt int64 `json:"last_viewed_at"`
MsgCount int64 `json:"msg_count"`
MentionCount int64 `json:"mention_count"`
NotifyProps StringMap `json:"notify_props"`
LastUpdateAt int64 `json:"last_update_at"`
ChannelId string `json:"channel_id"`
UserId string `json:"user_id"`
Roles string `json:"roles"`
LastViewedAt int64 `json:"last_viewed_at"`
MsgCount int64 `json:"msg_count"`
MentionCount int64 `json:"mention_count"`
NotifyProps StringMap `json:"notify_props"`
LastUpdateAt int64 `json:"last_update_at"`
SchemeUser bool `json:"scheme_user"`
SchemeAdmin bool `json:"scheme_admin"`
ExplicitRoles string `json:"explicit_roles"`
}
type ChannelMembers []ChannelMember
......
......@@ -22,6 +22,7 @@ const (
CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER = "inv_user"
CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER = "clear_session_user"
CLUSTER_EVENT_INVALIDATE_CACHE_FOR_ROLES = "inv_roles"
CLUSTER_EVENT_INVALIDATE_CACHE_FOR_SCHEMES = "inv_schemes"
CLUSTER_SEND_BEST_EFFORT = "best_effort"
CLUSTER_SEND_RELIABLE = "reliable"
......
......@@ -39,6 +39,7 @@ type Role struct {
DeleteAt int64 `json:"delete_at"`
Permissions []string `json:"permissions"`
SchemeManaged bool `json:"scheme_managed"`
BuiltIn bool `json:"built_in"`
}
type RolePatch struct {
......@@ -187,6 +188,7 @@ func MakeDefaultRoles() map[string]*Role {
PERMISSION_USE_SLASH_COMMANDS.Id,