mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-17200] Adds specific messages when guest is added or joins a channel (#11803)
* [MM-17200] Add user joined as guest message * [MM-17200] Add user added to channel as guest messages
This commit is contained in:
committed by
GitHub
parent
24e0d6f00d
commit
b8fa36cb41
@@ -1409,10 +1409,18 @@ func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError
|
||||
}
|
||||
|
||||
func (a *App) postJoinChannelMessage(user *model.User, channel *model.Channel) *model.AppError {
|
||||
message := fmt.Sprintf(utils.T("api.channel.join_channel.post_and_forget"), user.Username)
|
||||
postType := model.POST_JOIN_CHANNEL
|
||||
|
||||
if user.IsGuest() {
|
||||
message = fmt.Sprintf(utils.T("api.channel.guest_join_channel.post_and_forget"), user.Username)
|
||||
postType = model.POST_GUEST_JOIN_CHANNEL
|
||||
}
|
||||
|
||||
post := &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: fmt.Sprintf(utils.T("api.channel.join_channel.post_and_forget"), user.Username),
|
||||
Type: model.POST_JOIN_CHANNEL,
|
||||
Message: message,
|
||||
Type: postType,
|
||||
UserId: user.Id,
|
||||
Props: model.StringInterface{
|
||||
"username": user.Username,
|
||||
@@ -1527,10 +1535,18 @@ func (a *App) postLeaveChannelMessage(user *model.User, channel *model.Channel)
|
||||
}
|
||||
|
||||
func (a *App) PostAddToChannelMessage(user *model.User, addedUser *model.User, channel *model.Channel, postRootId string) *model.AppError {
|
||||
message := fmt.Sprintf(utils.T("api.channel.add_member.added"), addedUser.Username, user.Username)
|
||||
postType := model.POST_ADD_TO_CHANNEL
|
||||
|
||||
if addedUser.IsGuest() {
|
||||
message = fmt.Sprintf(utils.T("api.channel.add_guest.added"), addedUser.Username, user.Username)
|
||||
postType = model.POST_ADD_GUEST_TO_CHANNEL
|
||||
}
|
||||
|
||||
post := &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: fmt.Sprintf(utils.T("api.channel.add_member.added"), addedUser.Username, user.Username),
|
||||
Type: model.POST_ADD_TO_CHANNEL,
|
||||
Message: message,
|
||||
Type: postType,
|
||||
UserId: user.Id,
|
||||
RootId: postRootId,
|
||||
Props: model.StringInterface{
|
||||
|
||||
@@ -171,6 +171,10 @@
|
||||
"id": "api.bot.teams_channels.add_message_mobile",
|
||||
"translation": "Please add me to teams and channels you want me to interact in. To do this, use the browser or Mattermost Desktop App."
|
||||
},
|
||||
{
|
||||
"id": "api.channel.add_guest.added",
|
||||
"translation": "%v added to the channel as guest by %v."
|
||||
},
|
||||
{
|
||||
"id": "api.channel.add_member.added",
|
||||
"translation": "%v added to the channel by %v."
|
||||
@@ -259,6 +263,10 @@
|
||||
"id": "api.channel.delete_channel.type.invalid",
|
||||
"translation": "Unable to delete direct or group message channels"
|
||||
},
|
||||
{
|
||||
"id": "api.channel.guest_join_channel.post_and_forget",
|
||||
"translation": "%v joined the channel as guest."
|
||||
},
|
||||
{
|
||||
"id": "api.channel.join_channel.permissions.app_error",
|
||||
"translation": "You do not have the appropriate permissions"
|
||||
|
||||
@@ -21,12 +21,14 @@ const (
|
||||
POST_SYSTEM_GENERIC = "system_generic"
|
||||
POST_JOIN_LEAVE = "system_join_leave" // Deprecated, use POST_JOIN_CHANNEL or POST_LEAVE_CHANNEL instead
|
||||
POST_JOIN_CHANNEL = "system_join_channel"
|
||||
POST_GUEST_JOIN_CHANNEL = "system_guest_join_channel"
|
||||
POST_LEAVE_CHANNEL = "system_leave_channel"
|
||||
POST_JOIN_TEAM = "system_join_team"
|
||||
POST_LEAVE_TEAM = "system_leave_team"
|
||||
POST_AUTO_RESPONDER = "system_auto_responder"
|
||||
POST_ADD_REMOVE = "system_add_remove" // Deprecated, use POST_ADD_TO_CHANNEL or POST_REMOVE_FROM_CHANNEL instead
|
||||
POST_ADD_TO_CHANNEL = "system_add_to_channel"
|
||||
POST_ADD_GUEST_TO_CHANNEL = "system_add_guest_to_chan"
|
||||
POST_REMOVE_FROM_CHANNEL = "system_remove_from_channel"
|
||||
POST_MOVE_CHANNEL = "system_move_channel"
|
||||
POST_ADD_TO_TEAM = "system_add_to_team"
|
||||
@@ -231,10 +233,12 @@ func (o *Post) IsValid(maxPostSize int) *AppError {
|
||||
POST_AUTO_RESPONDER,
|
||||
POST_ADD_REMOVE,
|
||||
POST_JOIN_CHANNEL,
|
||||
POST_GUEST_JOIN_CHANNEL,
|
||||
POST_LEAVE_CHANNEL,
|
||||
POST_JOIN_TEAM,
|
||||
POST_LEAVE_TEAM,
|
||||
POST_ADD_TO_CHANNEL,
|
||||
POST_ADD_GUEST_TO_CHANNEL,
|
||||
POST_REMOVE_FROM_CHANNEL,
|
||||
POST_MOVE_CHANNEL,
|
||||
POST_ADD_TO_TEAM,
|
||||
|
||||
Reference in New Issue
Block a user