diff options
| -rw-r--r-- | server/channel/channel.go | 8 | ||||
| -rw-r--r-- | server/channel/command.go | 6 | ||||
| -rw-r--r-- | server/object/object.go | 2 | ||||
| -rw-r--r-- | server/server/command.go | 15 | ||||
| -rw-r--r-- | server/user/command.go | 4 | ||||
| -rw-r--r-- | server/user/user.go | 2 |
6 files changed, 17 insertions, 20 deletions
diff --git a/server/channel/channel.go b/server/channel/channel.go index c4d2000..6ef21ba 100644 --- a/server/channel/channel.go +++ b/server/channel/channel.go @@ -102,7 +102,7 @@ func (c *Channel) NameFor(uid string) string { } u := c.store.world.GetObject(member) if u != nil { - members = append(members, u.GetInfo().Fields[""]) + members = append(members, u.InfoFor(uid).Fields[""]) } } sort.Strings(members) @@ -223,16 +223,12 @@ func (c *Channel) Kind() string { } } -func (c *Channel) GetInfoFor(uid string) proto.Object { +func (c *Channel) InfoFor(uid string) proto.Object { return proto.Object { c.Kind(), c.id, map[string]string {"": c.NameFor(uid)}, } } -func (c *Channel) GetInfo() proto.Object { - return c.GetInfoFor("") -} - func (t Tombstone) GetInfo() proto.Object { return proto.Object { "gone", "", map[string]string {"": t.name, "kind": "channel"}, diff --git a/server/channel/command.go b/server/channel/command.go index 3cbedab..3434326 100644 --- a/server/channel/command.go +++ b/server/channel/command.go @@ -49,11 +49,11 @@ func (c *Channel) SendRequest(r session.Request) { r.Reply(proto.NewCmd("p", c.id, c.Put(m))) case "i": - r.Reply(proto.NewCmd("i", "", c.GetInfoFor(r.From.UserId))) + r.Reply(proto.NewCmd("i", "", c.InfoFor(r.From.UserId))) case "s": r.From.Subscribe(&c.Stream) - r.Reply(proto.NewCmd("i", "", c.GetInfoFor(r.From.UserId))) + r.Reply(proto.NewCmd("i", "", c.InfoFor(r.From.UserId))) case "u": r.From.Unsubscribe(&c.Stream) @@ -127,7 +127,7 @@ func (c *Channel) SendRequest(r session.Request) { cmd := proto.NewCmd("list", c.Id()) for m, _ := range c.Members() { u := c.store.world.GetObject(m).(*user.User) - cmd.Args = append(cmd.Args, u.GetInfo()) + cmd.Args = append(cmd.Args, u.InfoFor(r.From.UserId)) } r.Reply(cmd) diff --git a/server/object/object.go b/server/object/object.go index bae274a..e0d0239 100644 --- a/server/object/object.go +++ b/server/object/object.go @@ -7,7 +7,7 @@ import ( type Object interface { SendRequest(session.Request) - GetInfo() proto.Object + InfoFor(uid string) proto.Object } type World struct { diff --git a/server/server/command.go b/server/server/command.go index 14f8168..c1b3f24 100644 --- a/server/server/command.go +++ b/server/server/command.go @@ -32,7 +32,7 @@ func (s *server) SendRequest(r session.Request) { return } user.Anonymous = true - r.Reply(proto.NewCmd("you-are", "", user.GetInfo())) + r.Reply(proto.NewCmd("you-are", "", user.InfoFor(r.From.UserId))) r.From.UserId = user.Id() default: r.ReplyInvalid() @@ -59,14 +59,14 @@ func (s *server) SendRequest(r session.Request) { r.Reply(proto.Fail{"unknown-name", "", nil}.Cmd()) return } - info = u.GetInfo() + info = u.InfoFor(r.From.UserId) case "channel": c := s.channelStore.ByName(name) if c == nil { r.Reply(proto.Fail{"unknown-name", "", nil}.Cmd()) return } - info = c.GetInfo() + info = c.InfoFor(r.From.UserId) default: r.ReplyInvalid() return @@ -105,7 +105,7 @@ func (s *server) SendRequest(r session.Request) { u := s.world.GetObject(r.From.UserId).(*user.User) c.Join(u) c.SetMembership(u, channel.CreatorMembership) - r.Reply(proto.NewCmd("create", "", c.GetInfo())) + r.Reply(proto.NewCmd("create", "", c.InfoFor(r.From.UserId))) default: r.ReplyInvalid() } @@ -141,7 +141,7 @@ func (s *server) SendRequest(r session.Request) { among = append(among, member.Id) } c := s.channelStore.GetDirect(among) - r.Reply(proto.NewCmd("direct", "", c.GetInfo())) + r.Reply(proto.NewCmd("direct", "", c.InfoFor(r.From.UserId))) case "channels": if r.From.UserId == "" { @@ -155,7 +155,8 @@ func (s *server) SendRequest(r session.Request) { u := s.world.GetObject(r.From.UserId).(*user.User) var channels []proto.Object for c := range u.Channels { - channels = append(channels, s.world.GetObject(c).GetInfo()) + info := s.world.GetObject(c).InfoFor(r.From.UserId) + channels = append(channels, info) } r.Reply(proto.NewCmd("channels", "", channels...)) @@ -167,6 +168,6 @@ func (s *server) SendRequest(r session.Request) { } } -func (s *server) GetInfo() proto.Object { +func (s *server) InfoFor(uid string) proto.Object { return proto.Object {} } diff --git a/server/user/command.go b/server/user/command.go index 0c4f6d0..6eef81b 100644 --- a/server/user/command.go +++ b/server/user/command.go @@ -51,11 +51,11 @@ func (u *User) SendRequest(r session.Request) { r.ReplyOk() case "i": - r.Reply(proto.NewCmd("i", "", u.GetInfo())) + r.Reply(proto.NewCmd("i", "", u.InfoFor(r.From.UserId))) case "s": r.From.Subscribe(&u.Stream) - r.Reply(proto.NewCmd("i", "", u.GetInfo())) + r.Reply(proto.NewCmd("i", "", u.InfoFor(r.From.UserId))) case "u": r.From.Unsubscribe(&u.Stream) diff --git a/server/user/user.go b/server/user/user.go index 4d1d936..fb1022f 100644 --- a/server/user/user.go +++ b/server/user/user.go @@ -99,7 +99,7 @@ func (u *User) Delete() { u.store.world.PutObject(u.id, gone) } -func (u *User) GetInfo() proto.Object { +func (u *User) InfoFor(uid string) proto.Object { i := map[string]string {"": u.name} if u.status != "" { i["status"] = u.status |
