[MM-14588] Don't mark the channel as read when adding a member (#10680)

* add flag whether to mark channel as viewed for the requesting user

* remove marking channel as viewed when adding user to a channel
This commit is contained in:
Saturnino Abril
2019-04-27 07:22:12 +08:00
committed by GitHub
parent d144cc0e65
commit 7e590c7efe
7 changed files with 10 additions and 14 deletions

View File

@@ -1182,7 +1182,7 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
cm, err := c.App.AddChannelMember(member.UserId, channel, c.App.Session.UserId, postRootId, c.App.Session.Id)
cm, err := c.App.AddChannelMember(member.UserId, channel, c.App.Session.UserId, postRootId)
if err != nil {
c.Err = err
return

View File

@@ -915,7 +915,7 @@ func (a *App) AddUserToChannel(user *model.User, channel *model.Channel) (*model
return newMember, nil
}
func (a *App) AddChannelMember(userId string, channel *model.Channel, userRequestorId string, postRootId string, currentSessionId string) (*model.ChannelMember, *model.AppError) {
func (a *App) AddChannelMember(userId string, channel *model.Channel, userRequestorId string, postRootId string) (*model.ChannelMember, *model.AppError) {
if member, err := a.Srv.Store.Channel().GetMember(channel.Id, userId); err != nil {
if err.Id != store.MISSING_CHANNEL_MEMBER_ERROR {
return nil, err
@@ -970,10 +970,6 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
})
}
if userRequestor != nil {
a.MarkChannelsAsViewed([]string{channel.Id}, userRequestor.Id, currentSessionId)
}
return cm, nil
}

View File

@@ -438,7 +438,7 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) {
channel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN)
userRequestorId := ""
postRootId := ""
if _, err := th.App.AddChannelMember(user.Id, channel, userRequestorId, postRootId, ""); err != nil {
if _, err := th.App.AddChannelMember(user.Id, channel, userRequestorId, postRootId); err != nil {
t.Fatal("Failed to add user to channel. Error: " + err.Message)
}
@@ -738,7 +738,7 @@ func TestGetChannelMembersTimezones(t *testing.T) {
userRequestorId := ""
postRootId := ""
if _, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorId, postRootId, ""); err != nil {
if _, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorId, postRootId); err != nil {
t.Fatal("Failed to add user to channel. Error: " + err.Message)
}

View File

@@ -141,7 +141,7 @@ func (me *InviteProvider) DoCommand(a *App, args *model.CommandArgs, message str
}
}
if _, err := a.AddChannelMember(userProfile.Id, channelToJoin, args.Session.UserId, "", args.Session.Id); err != nil {
if _, err := a.AddChannelMember(userProfile.Id, channelToJoin, args.Session.UserId, ""); err != nil {
return &model.CommandResponse{
Text: args.T("api.command_invite.fail.app_error"),
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,

View File

@@ -392,7 +392,7 @@ func (api *PluginAPI) AddChannelMember(channelId, userId string) (*model.Channel
return nil, err
}
return api.app.AddChannelMember(userId, channel, userRequestorId, postRootId, "")
return api.app.AddChannelMember(userId, channel, userRequestorId, postRootId)
}
func (api *PluginAPI) GetChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError) {

View File

@@ -55,7 +55,7 @@ func (a *App) CreateDefaultMemberships(since int64) error {
)
}
_, err = a.AddChannelMember(userChannel.UserID, channel, "", "", "")
_, err = a.AddChannelMember(userChannel.UserID, channel, "", "")
if err != nil {
return err
}

View File

@@ -257,7 +257,7 @@ func TestCreateDefaultMemberships(t *testing.T) {
}
// Ensure members are in channel
_, err = th.App.AddChannelMember(scientist1.Id, experimentsChannel, "", "", "")
_, err = th.App.AddChannelMember(scientist1.Id, experimentsChannel, "", "")
if err != nil {
t.Errorf("unable to add user to channel: %s", err.Error())
}
@@ -267,7 +267,7 @@ func TestCreateDefaultMemberships(t *testing.T) {
if err != nil {
t.Errorf("unable to add user to team: %s", err.Error())
}
_, err = th.App.AddChannelMember(singer1.Id, experimentsChannel, "", "", "")
_, err = th.App.AddChannelMember(singer1.Id, experimentsChannel, "", "")
if err != nil {
t.Errorf("unable to add user to channel: %s", err.Error())
}
@@ -341,7 +341,7 @@ func TestDeleteGroupMemberships(t *testing.T) {
_, err = th.App.AddTeamMember(th.BasicTeam.Id, userID)
require.Nil(t, err)
_, err = th.App.AddChannelMember(userID, th.BasicChannel, "", "", "")
_, err = th.App.AddChannelMember(userID, th.BasicChannel, "", "")
require.Nil(t, err)
}