Member show on Activate and Hide on deactivate from channel member list and at_mention

Этот коммит содержится в:
Elias Nahum
2016-02-25 04:24:03 -03:00
родитель 6f319fc64c
Коммит f0084229a5
6 изменённых файлов: 93 добавлений и 1 удалений

Просмотреть файл

@@ -1510,6 +1510,8 @@ func UpdateActive(c *Context, user *model.User, active bool) *model.User {
RevokeAllSession(c, user.Id) RevokeAllSession(c, user.Id)
} }
<-Srv.Store.Channel().ExtraUpdateByUser(user.Id, model.GetMillis())
ruser := result.Data.([2]*model.User)[0] ruser := result.Data.([2]*model.User)[0]
options := utils.Cfg.GetSanitizeOptions() options := utils.Cfg.GetSanitizeOptions()
options["passwordupdate"] = false options["passwordupdate"] = false

Просмотреть файл

@@ -924,3 +924,25 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) S
return storeChannel return storeChannel
} }
func (s SqlChannelStore) ExtraUpdateByUser(userId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
_, err := s.GetMaster().Exec(
`UPDATE Channels SET ExtraUpdateAt = :Time
WHERE Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId);`,
map[string]interface{}{"UserId": userId, "Time": time})
if err != nil {
result.Err = model.NewLocAppError("SqlChannelStore.extraUpdated", "store.sql_channel.extra_updated.app_error", nil, "user_id="+userId+", "+err.Error())
}
storeChannel <- result
close(storeChannel)
}()
return storeChannel
}

Просмотреть файл

@@ -868,3 +868,67 @@ func TestGetMemberCount(t *testing.T) {
t.Fatal("got incorrect member count %v", result.Data) t.Fatal("got incorrect member count %v", result.Data)
} }
} }
func TestUpdateExtrasByUser(t *testing.T) {
Setup()
teamId := model.NewId()
c1 := model.Channel{
TeamId: teamId,
DisplayName: "Channel1",
Name: "a" + model.NewId() + "b",
Type: model.CHANNEL_OPEN,
}
Must(store.Channel().Save(&c1))
c2 := model.Channel{
TeamId: teamId,
DisplayName: "Channel2",
Name: "a" + model.NewId() + "b",
Type: model.CHANNEL_OPEN,
}
Must(store.Channel().Save(&c2))
t.Logf("c1.Id = %v", c1.Id)
u1 := model.User{
TeamId: teamId,
Email: model.NewId(),
DeleteAt: 0,
}
Must(store.User().Save(&u1))
m1 := model.ChannelMember{
ChannelId: c1.Id,
UserId: u1.Id,
NotifyProps: model.GetDefaultChannelNotifyProps(),
}
Must(store.Channel().SaveMember(&m1))
u1.DeleteAt = model.GetMillis()
Must(store.User().Update(&u1, true))
if result := <-store.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil {
t.Fatal("failed to update extras by user: %v", result.Err)
}
if result := <-store.Channel().GetExtraMembers(c1.Id, -1); result.Err != nil {
t.Fatal("failed to get extras: %v", result.Err)
} else if len(result.Data.([]model.ExtraMember)) != 0 {
t.Fatal("got incorrect member count %v", len(result.Data.([]model.ExtraMember)))
}
u1.DeleteAt = 0
Must(store.User().Update(&u1, true))
if result := <-store.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil {
t.Fatal("failed to update extras by user: %v", result.Err)
}
if result := <-store.Channel().GetExtraMembers(c1.Id, -1); result.Err != nil {
t.Fatal("failed to get extras: %v", result.Err)
} else if len(result.Data.([]model.ExtraMember)) != 1 {
t.Fatal("got incorrect member count %v", len(result.Data.([]model.ExtraMember)))
}
}

Просмотреть файл

@@ -85,6 +85,7 @@ type ChannelStore interface {
UpdateLastViewedAt(channelId string, userId string) StoreChannel UpdateLastViewedAt(channelId string, userId string) StoreChannel
IncrementMentionCount(channelId string, userId string) StoreChannel IncrementMentionCount(channelId string, userId string) StoreChannel
AnalyticsTypeCount(teamId string, channelType string) StoreChannel AnalyticsTypeCount(teamId string, channelType string) StoreChannel
ExtraUpdateByUser(userId string, time int64) StoreChannel
} }
type PostStore interface { type PostStore interface {

Просмотреть файл

@@ -2,6 +2,7 @@
// See License.txt for license information. // See License.txt for license information.
import UserStore from '../stores/user_store.jsx'; import UserStore from '../stores/user_store.jsx';
import ChannelStore from '../stores/channel_store.jsx';
import * as Client from '../utils/client.jsx'; import * as Client from '../utils/client.jsx';
import * as AsyncClient from '../utils/async_client.jsx'; import * as AsyncClient from '../utils/async_client.jsx';
import * as Utils from '../utils/utils.jsx'; import * as Utils from '../utils/utils.jsx';
@@ -71,6 +72,7 @@ export default class MemberListTeamItem extends React.Component {
Client.updateActive(this.props.user.id, true, Client.updateActive(this.props.user.id, true,
() => { () => {
AsyncClient.getProfiles(); AsyncClient.getProfiles();
AsyncClient.getChannelExtraInfo(ChannelStore.getCurrentId());
}, },
(err) => { (err) => {
this.setState({serverError: err.message}); this.setState({serverError: err.message});
@@ -81,6 +83,7 @@ export default class MemberListTeamItem extends React.Component {
Client.updateActive(this.props.user.id, false, Client.updateActive(this.props.user.id, false,
() => { () => {
AsyncClient.getProfiles(); AsyncClient.getProfiles();
AsyncClient.getChannelExtraInfo(ChannelStore.getCurrentId());
}, },
(err) => { (err) => {
this.setState({serverError: err.message}); this.setState({serverError: err.message});

Просмотреть файл

@@ -83,7 +83,7 @@ export default class AtMentionProvider {
if (captured) { if (captured) {
const usernamePrefix = captured[1]; const usernamePrefix = captured[1];
const users = UserStore.getProfiles(); const users = UserStore.getActiveOnlyProfiles(true);
let filtered = []; let filtered = [];
for (const id of Object.keys(users)) { for (const id of Object.keys(users)) {