summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/channel/channel.go15
-rw-r--r--server/channel/command.go5
2 files changed, 18 insertions, 2 deletions
diff --git a/server/channel/channel.go b/server/channel/channel.go
index 056b942..c4d2000 100644
--- a/server/channel/channel.go
+++ b/server/channel/channel.go
@@ -88,11 +88,18 @@ func (cs *ChannelStore) ByName(name string) *Channel {
}
func (c *Channel) Name() string {
+ return c.NameFor("")
+}
+
+func (c *Channel) NameFor(uid string) string {
if !c.isDirect {
return c.name
} else {
var members []string
for member := range c.members {
+ if member == uid && len(c.members) > 1 {
+ continue
+ }
u := c.store.world.GetObject(member)
if u != nil {
members = append(members, u.GetInfo().Fields[""])
@@ -216,8 +223,14 @@ func (c *Channel) Kind() string {
}
}
+func (c *Channel) GetInfoFor(uid string) proto.Object {
+ return proto.Object {
+ c.Kind(), c.id, map[string]string {"": c.NameFor(uid)},
+ }
+}
+
func (c *Channel) GetInfo() proto.Object {
- return proto.Object {c.Kind(), c.id, map[string]string {"": c.Name()}}
+ return c.GetInfoFor("")
}
func (t Tombstone) GetInfo() proto.Object {
diff --git a/server/channel/command.go b/server/channel/command.go
index c4eb13b..3cbedab 100644
--- a/server/channel/command.go
+++ b/server/channel/command.go
@@ -48,9 +48,12 @@ func (c *Channel) SendRequest(r session.Request) {
m.Fields["f"] = r.From.UserId
r.Reply(proto.NewCmd("p", c.id, c.Put(m)))
+ case "i":
+ r.Reply(proto.NewCmd("i", "", c.GetInfoFor(r.From.UserId)))
+
case "s":
r.From.Subscribe(&c.Stream)
- r.Reply(proto.NewCmd("i", "", c.GetInfo()))
+ r.Reply(proto.NewCmd("i", "", c.GetInfoFor(r.From.UserId)))
case "u":
r.From.Unsubscribe(&c.Stream)