diff --git a/app/channel.go b/app/channel.go index 54e0f63984..fb86a20051 100644 --- a/app/channel.go +++ b/app/channel.go @@ -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{ diff --git a/i18n/en.json b/i18n/en.json index 69ff27bef6..a50018668c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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" diff --git a/model/post.go b/model/post.go index 727296915d..c2dad69163 100644 --- a/model/post.go +++ b/model/post.go @@ -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,