[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d144cc0e65
Коммит
7e590c7efe
@@ -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 {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -915,7 +915,7 @@ func (a *App) AddUserToChannel(user *model.User, channel *model.Channel) (*model
|
|||||||
return newMember, nil
|
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 member, err := a.Srv.Store.Channel().GetMember(channel.Id, userId); err != nil {
|
||||||
if err.Id != store.MISSING_CHANNEL_MEMBER_ERROR {
|
if err.Id != store.MISSING_CHANNEL_MEMBER_ERROR {
|
||||||
return nil, err
|
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
|
return cm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) {
|
|||||||
channel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN)
|
channel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN)
|
||||||
userRequestorId := ""
|
userRequestorId := ""
|
||||||
postRootId := ""
|
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)
|
t.Fatal("Failed to add user to channel. Error: " + err.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,7 +738,7 @@ func TestGetChannelMembersTimezones(t *testing.T) {
|
|||||||
|
|
||||||
userRequestorId := ""
|
userRequestorId := ""
|
||||||
postRootId := ""
|
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)
|
t.Fatal("Failed to add user to channel. Error: " + err.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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{
|
return &model.CommandResponse{
|
||||||
Text: args.T("api.command_invite.fail.app_error"),
|
Text: args.T("api.command_invite.fail.app_error"),
|
||||||
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ func (api *PluginAPI) AddChannelMember(channelId, userId string) (*model.Channel
|
|||||||
return nil, err
|
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) {
|
func (api *PluginAPI) GetChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError) {
|
||||||
|
|||||||
@@ -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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure members are in channel
|
// Ensure members are in channel
|
||||||
_, err = th.App.AddChannelMember(scientist1.Id, experimentsChannel, "", "", "")
|
_, err = th.App.AddChannelMember(scientist1.Id, experimentsChannel, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unable to add user to channel: %s", err.Error())
|
t.Errorf("unable to add user to channel: %s", err.Error())
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unable to add user to team: %s", err.Error())
|
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 {
|
if err != nil {
|
||||||
t.Errorf("unable to add user to channel: %s", err.Error())
|
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)
|
_, err = th.App.AddTeamMember(th.BasicTeam.Id, userID)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
_, err = th.App.AddChannelMember(userID, th.BasicChannel, "", "", "")
|
_, err = th.App.AddChannelMember(userID, th.BasicChannel, "", "")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user