summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-02-09 20:53:04 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-02-10 08:29:57 -0500
commit1eab2ef39350c1035864918f366ab593d23e0f5a (patch)
tree405f8b2310c0c0e14e0d60fe88e483c1320dd7f0 /store
parent6225522478f61aa134d167954d3116c72a6148c3 (diff)
downloadchat-1eab2ef39350c1035864918f366ab593d23e0f5a.tar.gz
chat-1eab2ef39350c1035864918f366ab593d23e0f5a.tar.bz2
chat-1eab2ef39350c1035864918f366ab593d23e0f5a.zip
Stopped returning inactive members with getExtraInfo calls
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store.go31
-rw-r--r--store/sql_channel_store_test.go12
2 files changed, 41 insertions, 2 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 8b52dae12..87ee2bb11 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -615,9 +615,36 @@ func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChann
var err error
if limit != -1 {
- _, err = s.GetReplica().Select(&members, "SELECT Id, Nickname, Email, ChannelMembers.Roles, Username FROM ChannelMembers, Users WHERE ChannelMembers.UserId = Users.Id AND ChannelId = :ChannelId LIMIT :Limit", map[string]interface{}{"ChannelId": channelId, "Limit": limit})
+ _, err = s.GetReplica().Select(&members, `
+ SELECT
+ Id,
+ Nickname,
+ Email,
+ ChannelMembers.Roles,
+ Username
+ FROM
+ ChannelMembers,
+ Users
+ WHERE
+ ChannelMembers.UserId = Users.Id
+ AND Users.DeleteAt = 0
+ AND ChannelId = :ChannelId
+ LIMIT :Limit`, map[string]interface{}{"ChannelId": channelId, "Limit": limit})
} else {
- _, err = s.GetReplica().Select(&members, "SELECT Id, Nickname, Email, ChannelMembers.Roles, Username FROM ChannelMembers, Users WHERE ChannelMembers.UserId = Users.Id AND ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
+ _, err = s.GetReplica().Select(&members, `
+ SELECT
+ Id,
+ Nickname,
+ Email,
+ ChannelMembers.Roles,
+ Username
+ FROM
+ ChannelMembers,
+ Users
+ WHERE
+ ChannelMembers.UserId = Users.Id
+ AND Users.DeleteAt = 0
+ AND ChannelId = :ChannelId`, map[string]interface{}{"ChannelId": channelId})
}
if err != nil {
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index a3b0c2286..816a85aef 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -377,6 +377,18 @@ func TestChannelMemberStore(t *testing.T) {
if t4 != t3 {
t.Fatal("Should not update time upon failure")
}
+
+ // rejoin the channel and make sure that an inactive user isn't returned by GetExtraMambers
+ Must(store.Channel().SaveMember(&o2))
+
+ u2.DeleteAt = 1000
+ Must(store.User().Update(&u2, true))
+
+ if result := <-store.Channel().GetExtraMembers(o1.ChannelId, 20); result.Err != nil {
+ t.Fatal(result.Err)
+ } else if extraMembers := result.Data.([]model.ExtraMember); len(extraMembers) != 1 {
+ t.Fatal("should have 1 extra members")
+ }
}
func TestChannelDeleteMemberStore(t *testing.T) {