1// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
2// See LICENSE.txt for license information.
3
4package model
5
6import (
7	"github.com/mattermost/mattermost-server/v6/shared/i18n"
8)
9
10type CommandArgs struct {
11	UserId          string             `json:"user_id"`
12	ChannelId       string             `json:"channel_id"`
13	TeamId          string             `json:"team_id"`
14	RootId          string             `json:"root_id"`
15	ParentId        string             `json:"parent_id"`
16	TriggerId       string             `json:"trigger_id,omitempty"`
17	Command         string             `json:"command"`
18	SiteURL         string             `json:"-"`
19	T               i18n.TranslateFunc `json:"-"`
20	UserMentions    UserMentionMap     `json:"-"`
21	ChannelMentions ChannelMentionMap  `json:"-"`
22
23	// DO NOT USE Session field is deprecated. MM-26398
24	Session Session `json:"-"`
25}
26
27// AddUserMention adds or overrides an entry in UserMentions with name username
28// and identifier userId
29func (o *CommandArgs) AddUserMention(username, userId string) {
30	if o.UserMentions == nil {
31		o.UserMentions = make(UserMentionMap)
32	}
33
34	o.UserMentions[username] = userId
35}
36
37// AddChannelMention adds or overrides an entry in ChannelMentions with name
38// channelName and identifier channelId
39func (o *CommandArgs) AddChannelMention(channelName, channelId string) {
40	if o.ChannelMentions == nil {
41		o.ChannelMentions = make(ChannelMentionMap)
42	}
43
44	o.ChannelMentions[channelName] = channelId
45}
46