summaryrefslogtreecommitdiff
path: root/server/channel
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2025-10-22 15:48:40 -0500
committerraven <citrons@mondecitronne.com>2025-10-22 16:23:32 -0500
commit4b54a1d11fd0fa355b244637612a3fd0af18c60c (patch)
tree43a2d2d1feff2caf40a2e33b6ac4d61185708ab3 /server/channel
parent9126f2329aa21645e0d5622b0eeed402273efa95 (diff)
events generated from other clients on the same account
Diffstat (limited to 'server/channel')
-rw-r--r--server/channel/channel.go14
-rw-r--r--server/channel/command.go6
2 files changed, 14 insertions, 6 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
}
diff --git a/server/channel/command.go b/server/channel/command.go
index 04e45a2..92ae2cc 100644
--- a/server/channel/command.go
+++ b/server/channel/command.go
@@ -46,7 +46,7 @@ func (c *Channel) SendRequest(r session.Request) {
}
m.Fields["f"] = r.From.UserId
- r.Reply(proto.NewCmd("p", c.id, c.Put(m)))
+ r.Reply(proto.NewCmd("p", c.id, c.Put(m, r.From)))
case "i":
r.Reply(proto.NewCmd("i", "", c.InfoFor(r.From.UserId)))
@@ -66,6 +66,7 @@ func (c *Channel) SendRequest(r session.Request) {
r.Reply(err.Cmd())
} else {
r.ReplyOk()
+ u.PrivateStream.Event(proto.NewCmd("join", c.id))
}
case "leave":
@@ -75,6 +76,7 @@ func (c *Channel) SendRequest(r session.Request) {
r.Reply(err.Cmd())
} else {
r.ReplyOk()
+ u.PrivateStream.Event(proto.NewCmd("leave", c.id))
}
case "delete":
@@ -249,7 +251,7 @@ func (c *Channel) SendRequest(r session.Request) {
return
}
c.SetMembership(id, new)
- c.Put(o)
+ c.Put(o, r.From)
i := new.GetInfo()
i.Fields[""] = id