diff options
Diffstat (limited to 'server/channel/channel.go')
| -rw-r--r-- | server/channel/channel.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/server/channel/channel.go b/server/channel/channel.go index 81d5439..9ec0b41 100644 --- a/server/channel/channel.go +++ b/server/channel/channel.go @@ -178,7 +178,7 @@ func (c *Channel) Rename(name string) *proto.Fail { return nil } -func (c *Channel) Put(m proto.Object) proto.Object { +func (c *Channel) Put(m proto.Object, From *session.Session) proto.Object { m.Id = proto.GenId() m.Fields["t"] = proto.Timestamp() err := c.kind.db.Update(func(tx *bolt.Tx) error { @@ -206,7 +206,7 @@ func (c *Channel) Put(m proto.Object) proto.Object { log.Fatal("error updating database: ", err) } for s, _ := range c.Stream.Subscribers() { - if m.Fields["f"] == s.UserId { + if From == s { continue } if c.GetMembership(s.UserId).See { @@ -284,20 +284,26 @@ func (c *Channel) History(min, max int) []proto.Object { } func (c *Channel) Join(u *user.User) *proto.Fail { + if c.isDirect { + return &proto.Fail {"invalid", "", nil} + } if c.GetMembership(u.Id()).Yes { return nil } c.SetMembership(u.Id(), c.GetDefaultMembership()) - c.Put(proto.Object{"join", "", map[string]string {"f": u.Id()}}) + c.Put(proto.Object{"join", "", map[string]string {"f": u.Id()}}, nil) return nil } func (c *Channel) Leave(u *user.User) *proto.Fail { + if c.isDirect { + return &proto.Fail {"invalid", "", nil} + } if !c.GetMembership(u.Id()).Yes { return nil } c.SetMembership(u.Id(), Membership {Yes: false}) - c.Put(proto.Object{"leave", "", map[string]string {"f": u.Id()}}) + c.Put(proto.Object{"leave", "", map[string]string {"f": u.Id()}}, nil) return nil } |
