PLT-6759 Show deactivated users in GMs (#6703)
* Show deactivated users in GMs * Fix runtime error when DMing deactivated user
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
ac4e9909fa
Коммит
3f1fca9463
@@ -63,7 +63,10 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
|
|||||||
otherUserId = userIds[0]
|
otherUserId = userIds[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
mentionedUserIds[otherUserId] = true
|
if _, ok := profileMap[otherUserId]; ok {
|
||||||
|
mentionedUserIds[otherUserId] = true
|
||||||
|
}
|
||||||
|
|
||||||
if post.Props["from_webhook"] == "true" {
|
if post.Props["from_webhook"] == "true" {
|
||||||
mentionedUserIds[post.UserId] = true
|
mentionedUserIds[post.UserId] = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ func TestSendNotifications(t *testing.T) {
|
|||||||
|
|
||||||
AddUserToChannel(th.BasicUser2, th.BasicChannel)
|
AddUserToChannel(th.BasicUser2, th.BasicChannel)
|
||||||
|
|
||||||
post1, postErr := CreatePost(&model.Post{
|
post1, err := CreatePost(&model.Post{
|
||||||
UserId: th.BasicUser.Id,
|
UserId: th.BasicUser.Id,
|
||||||
ChannelId: th.BasicChannel.Id,
|
ChannelId: th.BasicChannel.Id,
|
||||||
Message: "@" + th.BasicUser2.Username,
|
Message: "@" + th.BasicUser2.Username,
|
||||||
}, th.BasicTeam.Id, true)
|
}, th.BasicTeam.Id, true)
|
||||||
|
|
||||||
if postErr != nil {
|
if err != nil {
|
||||||
t.Fatal(postErr)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mentions, err := SendNotifications(post1, th.BasicTeam, th.BasicChannel, th.BasicUser)
|
mentions, err := SendNotifications(post1, th.BasicTeam, th.BasicChannel, th.BasicUser)
|
||||||
@@ -34,6 +34,44 @@ func TestSendNotifications(t *testing.T) {
|
|||||||
t.Log(mentions)
|
t.Log(mentions)
|
||||||
t.Fatal("user should have been mentioned")
|
t.Fatal("user should have been mentioned")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dm, err := CreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
post2, err := CreatePost(&model.Post{
|
||||||
|
UserId: th.BasicUser.Id,
|
||||||
|
ChannelId: dm.Id,
|
||||||
|
Message: "dm message",
|
||||||
|
}, th.BasicTeam.Id, true)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = SendNotifications(post2, th.BasicTeam, dm, th.BasicUser)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateActive(th.BasicUser2, false)
|
||||||
|
InvalidateAllCaches()
|
||||||
|
|
||||||
|
post3, err := CreatePost(&model.Post{
|
||||||
|
UserId: th.BasicUser.Id,
|
||||||
|
ChannelId: dm.Id,
|
||||||
|
Message: "dm message",
|
||||||
|
}, th.BasicTeam.Id, true)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = SendNotifications(post3, th.BasicTeam, dm, th.BasicUser)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetExplicitMentions(t *testing.T) {
|
func TestGetExplicitMentions(t *testing.T) {
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ func (us SqlUserStore) GetProfilesInChannel(channelId string, offset int, limit
|
|||||||
|
|
||||||
var users []*model.User
|
var users []*model.User
|
||||||
|
|
||||||
query := "SELECT Users.* FROM Users, ChannelMembers WHERE ChannelMembers.ChannelId = :ChannelId AND Users.Id = ChannelMembers.UserId AND Users.DeleteAt = 0 ORDER BY Users.Username ASC LIMIT :Limit OFFSET :Offset"
|
query := "SELECT Users.* FROM Users, ChannelMembers WHERE ChannelMembers.ChannelId = :ChannelId AND Users.Id = ChannelMembers.UserId ORDER BY Users.Username ASC LIMIT :Limit OFFSET :Offset"
|
||||||
|
|
||||||
if _, err := us.GetReplica().Select(&users, query, map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit}); err != nil {
|
if _, err := us.GetReplica().Select(&users, query, map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit}); err != nil {
|
||||||
result.Err = model.NewLocAppError("SqlUserStore.GetProfilesInChannel", "store.sql_user.get_profiles.app_error", nil, err.Error())
|
result.Err = model.NewLocAppError("SqlUserStore.GetProfilesInChannel", "store.sql_user.get_profiles.app_error", nil, err.Error())
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default class ChannelHeader extends React.Component {
|
|||||||
getStateFromStores() {
|
getStateFromStores() {
|
||||||
const channel = ChannelStore.get(this.props.channelId);
|
const channel = ChannelStore.get(this.props.channelId);
|
||||||
const stats = ChannelStore.getStats(this.props.channelId);
|
const stats = ChannelStore.getStats(this.props.channelId);
|
||||||
const users = UserStore.getProfileListInChannel(this.props.channelId);
|
const users = UserStore.getProfileListInChannel(this.props.channelId, false, true);
|
||||||
|
|
||||||
let otherUserId = null;
|
let otherUserId = null;
|
||||||
if (channel && channel.type === 'D') {
|
if (channel && channel.type === 'D') {
|
||||||
@@ -227,7 +227,7 @@ export default class ChannelHeader extends React.Component {
|
|||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.TOGGLE_DM_MODAL,
|
type: ActionTypes.TOGGLE_DM_MODAL,
|
||||||
value: true,
|
value: true,
|
||||||
startingUsers: UserStore.getProfileListInChannel(this.props.channelId, true)
|
startingUsers: UserStore.getProfileListInChannel(this.props.channelId, true, false)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default class MemberListChannel extends React.Component {
|
|||||||
const stats = ChannelStore.getCurrentStats();
|
const stats = ChannelStore.getCurrentStats();
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
users: UserStore.getProfileListInChannel(),
|
users: UserStore.getProfileListInChannel(ChannelStore.getCurrentId(), false, true),
|
||||||
teamMembers: Object.assign({}, TeamStore.getMembersInTeam()),
|
teamMembers: Object.assign({}, TeamStore.getMembersInTeam()),
|
||||||
channelMembers: Object.assign({}, ChannelStore.getMembersInChannel()),
|
channelMembers: Object.assign({}, ChannelStore.getMembersInChannel()),
|
||||||
total: stats.member_count,
|
total: stats.member_count,
|
||||||
@@ -81,7 +81,7 @@ export default class MemberListChannel extends React.Component {
|
|||||||
if (this.term) {
|
if (this.term) {
|
||||||
users = searchProfilesInCurrentChannel(store.getState(), this.term);
|
users = searchProfilesInCurrentChannel(store.getState(), this.term);
|
||||||
} else {
|
} else {
|
||||||
users = UserStore.getProfileListInChannel();
|
users = UserStore.getProfileListInChannel(ChannelStore.getCurrentId(), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
@@ -390,10 +390,10 @@ class UserStoreClass extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfileListInChannel(channelId = ChannelStore.getCurrentId(), skipCurrent = false) {
|
getProfileListInChannel(channelId = ChannelStore.getCurrentId(), skipCurrent = false, skipInactive = false) {
|
||||||
const userIds = Array.from(Selectors.getUserIdsInChannels(store.getState())[channelId] || []);
|
const userIds = Array.from(Selectors.getUserIdsInChannels(store.getState())[channelId] || []);
|
||||||
|
|
||||||
return this.getProfileListForIds(userIds, skipCurrent, false);
|
return this.getProfileListForIds(userIds, skipCurrent, skipInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveProfileNotInChannel(channelId = ChannelStore.getCurrentId(), profile) {
|
saveProfileNotInChannel(channelId = ChannelStore.getCurrentId(), profile) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user