Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
92 lines
2.2 KiB
Go
92 lines
2.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
const (
|
|
// Different types of mentions ordered by their priority from lowest to highest
|
|
|
|
// A placeholder that should never be used in practice
|
|
NoMention MentionType = iota
|
|
|
|
// The post is in a GM
|
|
GMMention
|
|
|
|
// The post is in a thread that the user has commented on
|
|
ThreadMention
|
|
|
|
// The post is a comment on a thread started by the user
|
|
CommentMention
|
|
|
|
// The post contains an at-channel, at-all, or at-here
|
|
ChannelMention
|
|
|
|
// The post is a DM
|
|
DMMention
|
|
|
|
// The post contains an at-mention for the user
|
|
KeywordMention
|
|
|
|
// The post contains a group mention for the user
|
|
GroupMention
|
|
)
|
|
|
|
type MentionType int
|
|
|
|
type MentionResults struct {
|
|
// Mentions maps the ID of each user that was mentioned to how they were mentioned.
|
|
Mentions map[string]MentionType
|
|
|
|
// GroupMentions maps the ID of each group that was mentioned to how it was mentioned.
|
|
GroupMentions map[string]MentionType
|
|
|
|
// OtherPotentialMentions contains a list of strings that looked like mentions, but didn't have
|
|
// a corresponding keyword.
|
|
OtherPotentialMentions []string
|
|
|
|
// HereMentioned is true if the message contained @here.
|
|
HereMentioned bool
|
|
|
|
// AllMentioned is true if the message contained @all.
|
|
AllMentioned bool
|
|
|
|
// ChannelMentioned is true if the message contained @channel.
|
|
ChannelMentioned bool
|
|
}
|
|
|
|
func (m *MentionResults) isUserMentioned(userID string) bool {
|
|
if _, ok := m.Mentions[userID]; ok {
|
|
return true
|
|
}
|
|
|
|
if _, ok := m.GroupMentions[userID]; ok {
|
|
return true
|
|
}
|
|
|
|
return m.HereMentioned || m.AllMentioned || m.ChannelMentioned
|
|
}
|
|
|
|
func (m *MentionResults) addMention(userID string, mentionType MentionType) {
|
|
if m.Mentions == nil {
|
|
m.Mentions = make(map[string]MentionType)
|
|
}
|
|
|
|
if currentType, ok := m.Mentions[userID]; ok && currentType >= mentionType {
|
|
return
|
|
}
|
|
|
|
m.Mentions[userID] = mentionType
|
|
}
|
|
|
|
func (m *MentionResults) removeMention(userID string) {
|
|
delete(m.Mentions, userID)
|
|
}
|
|
|
|
func (m *MentionResults) addGroupMention(groupID string) {
|
|
if m.GroupMentions == nil {
|
|
m.GroupMentions = make(map[string]MentionType)
|
|
}
|
|
|
|
m.GroupMentions[groupID] = GroupMention
|
|
}
|