[MM-59361] custom groups & read only channels (#28892)
* added group mention, read only view and post event tracking --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c64215f6c2
Коммит
a532b70317
@@ -1585,7 +1585,7 @@ func (a *App) addUserToChannel(c request.CTX, user *model.User, channel *model.C
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(
|
||||
telemetry.TrackGuestFeature,
|
||||
"add_guest_to_channel",
|
||||
map[string]any{"user_actual_id": user.Id})
|
||||
map[string]any{telemetry.TrackPropertyUser: user.Id})
|
||||
}
|
||||
|
||||
a.Srv().Platform().InvalidateChannelCacheForUser(user.Id)
|
||||
@@ -2663,10 +2663,12 @@ func (a *App) SetActiveChannel(c request.CTX, userID string, channelID string) *
|
||||
|
||||
oldStatus := model.StatusOffline
|
||||
|
||||
oldChannelID := ""
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userID, Status: model.StatusOnline, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelID}
|
||||
} else {
|
||||
oldStatus = status.Status
|
||||
oldChannelID = status.ActiveChannel
|
||||
status.ActiveChannel = channelID
|
||||
if !status.Manual && channelID != "" {
|
||||
status.Status = model.StatusOnline
|
||||
@@ -2680,6 +2682,24 @@ func (a *App) SetActiveChannel(c request.CTX, userID string, channelID string) *
|
||||
a.Srv().Platform().BroadcastStatus(status)
|
||||
}
|
||||
|
||||
if channelID != "" && oldChannelID != channelID {
|
||||
// is this a read-only channel?
|
||||
isReadOnly, ircErr := a.Srv().Store().Channel().IsReadOnlyChannel(channelID)
|
||||
if ircErr != nil {
|
||||
mlog.Warn("Error trying to check if it is a readonly channel", mlog.Err(ircErr))
|
||||
}
|
||||
if isReadOnly {
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(
|
||||
telemetry.TrackReadOnlyFeature,
|
||||
"read_only_channel_viewed",
|
||||
map[string]any{
|
||||
telemetry.TrackPropertyUser: userID,
|
||||
telemetry.TrackPropertyChannel: channelID,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -869,17 +869,20 @@ func (a *App) SendNotifications(c request.CTX, post *model.Post, team *model.Tea
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(
|
||||
telemetry.TrackGuestFeature,
|
||||
"post_mentioned_guest",
|
||||
map[string]any{"user_actual_id": user.Id, "post_owner_id": sender.Id},
|
||||
map[string]any{telemetry.TrackPropertyUser: user.Id, telemetry.TrackPropertyPostAuthor: sender.Id},
|
||||
)
|
||||
} else if reason == DMMention {
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(
|
||||
telemetry.TrackGuestFeature,
|
||||
"direct_message_to_guest",
|
||||
map[string]any{"user_actual_id": user.Id, "post_owner_id": sender.Id},
|
||||
map[string]any{telemetry.TrackPropertyUser: user.Id, telemetry.TrackPropertyPostAuthor: sender.Id},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
for groupId := range mentions.GroupMentions {
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(telemetry.TrackGroupsFeature, "post_mentioned_custom_group", map[string]any{telemetry.TrackPropertyUser: sender.Id, telemetry.TrackPropertyGroup: groupId, "group_size": groups[groupId].MemberCount})
|
||||
}
|
||||
return mentionedUsersList, nil
|
||||
}
|
||||
|
||||
@@ -1576,6 +1579,13 @@ func (a *App) insertGroupMentions(senderID string, group *model.Group, channel *
|
||||
for _, user := range outOfChannelGroupMembers {
|
||||
potentialGroupMembersMentioned = append(potentialGroupMembersMentioned, user.Username)
|
||||
}
|
||||
if len(potentialGroupMembersMentioned) != 0 {
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(
|
||||
telemetry.TrackGroupsFeature,
|
||||
"invite_group_to_channel__post",
|
||||
map[string]any{telemetry.TrackPropertyUser: senderID, telemetry.TrackPropertyGroup: group.Id},
|
||||
)
|
||||
}
|
||||
if mentions.OtherPotentialMentions == nil {
|
||||
mentions.OtherPotentialMentions = potentialGroupMembersMentioned
|
||||
} else {
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store/sqlstore"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/cache"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/telemetry"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -79,6 +80,22 @@ func (a *App) CreatePostAsUser(c request.CTX, post *model.Post, currentSessionId
|
||||
)
|
||||
}
|
||||
}
|
||||
if channel.SchemeId != nil && *channel.SchemeId != "" {
|
||||
isReadOnly, ircErr := a.Srv().Store().Channel().IsChannelReadOnlyScheme(*channel.SchemeId)
|
||||
if ircErr != nil {
|
||||
mlog.Warn("Error trying to check if it was a post to a readonly channel", mlog.Err(ircErr))
|
||||
}
|
||||
if isReadOnly {
|
||||
a.Srv().telemetryService.SendTelemetryForFeature(
|
||||
telemetry.TrackReadOnlyFeature,
|
||||
"read_only_channel_posted",
|
||||
map[string]any{
|
||||
telemetry.TrackPropertyUser: post.UserId,
|
||||
telemetry.TrackPropertyChannel: post.ChannelId,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return rp, nil
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/telemetry"
|
||||
)
|
||||
|
||||
type InviteProvider struct {
|
||||
@@ -185,23 +186,23 @@ func (i *InviteProvider) doCommand(a *app.App, c request.CTX, args *model.Comman
|
||||
return ""
|
||||
}
|
||||
|
||||
func (i *InviteProvider) getUsersFromMentionName(a *app.App, mentionName string) []*model.User {
|
||||
func (i *InviteProvider) getUsersFromMentionName(a *app.App, mentionName string) ([]*model.User, *model.Group) {
|
||||
userProfile, err := a.Srv().Store().User().GetByUsername(mentionName)
|
||||
if err == nil && userProfile.DeleteAt == 0 {
|
||||
return []*model.User{userProfile}
|
||||
return []*model.User{userProfile}, nil
|
||||
}
|
||||
|
||||
group, appErr := a.GetGroupByName(mentionName, model.GroupSearchOpts{FilterAllowReference: true})
|
||||
if appErr != nil || group == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
members, appErr := a.GetGroupMemberUsers(group.Id)
|
||||
if appErr != nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return members
|
||||
return members, group
|
||||
}
|
||||
|
||||
func (i *InviteProvider) parseMessage(a *app.App, c request.CTX, args *model.CommandArgs, resps *[]string, message string) ([]*model.User, []*model.Channel, string) {
|
||||
@@ -217,7 +218,14 @@ func (i *InviteProvider) parseMessage(a *app.App, c request.CTX, args *model.Com
|
||||
|
||||
if msg[0] == '@' || (msg[0] != '~' && j == 0) {
|
||||
targetMentionName := strings.TrimPrefix(msg, "@")
|
||||
users := i.getUsersFromMentionName(a, targetMentionName)
|
||||
users, group := i.getUsersFromMentionName(a, targetMentionName)
|
||||
if group != nil {
|
||||
a.Srv().GetTelemetryService().SendTelemetryForFeature(
|
||||
telemetry.TrackGroupsFeature,
|
||||
"invite_group_to_channel__command",
|
||||
map[string]any{telemetry.TrackPropertyUser: c.Session().UserId, telemetry.TrackPropertyGroup: group.Id},
|
||||
)
|
||||
}
|
||||
if len(users) == 0 {
|
||||
*resps = append(*resps, args.T("api.command_invite.missing_user.app_error", map[string]any{
|
||||
"User": targetMentionName,
|
||||
|
||||
Ссылка в новой задаче
Block a user