summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-05-27 02:38:59 -0500
committercitrons <citrons@mondecitronne.com>2025-05-27 02:40:01 -0500
commit4622c6cabc18cc7f4a6b2f41bf6472d86528aaea (patch)
treeb5e5b6fa2a706d31140666cc06709fb403bc8eaf /server
parent874c492e5c471d4ee9bde1638dc675999b8b1f51 (diff)
retain deleted channel names
Diffstat (limited to 'server')
-rw-r--r--server/channel/channel.go19
-rw-r--r--server/channel/command.go17
2 files changed, 35 insertions, 1 deletions
diff --git a/server/channel/channel.go b/server/channel/channel.go
index 50b43b6..9a3134e 100644
--- a/server/channel/channel.go
+++ b/server/channel/channel.go
@@ -10,6 +10,7 @@ import (
type ChannelStore struct {
world *object.World
byName map[string]*Channel
+ deleted map[string]Tombstone
}
type Channel struct {
@@ -23,8 +24,14 @@ type Channel struct {
Stream session.Stream
}
+type Tombstone struct {
+ name string
+}
+
func NewStore(world *object.World) *ChannelStore {
- return &ChannelStore {world, make(map[string]*Channel)}
+ return &ChannelStore {
+ world, make(map[string]*Channel), make(map[string]Tombstone),
+ }
}
func (cs *ChannelStore) CreateChannel(name string) (*Channel, *proto.Fail) {
@@ -139,6 +146,10 @@ func (c *Channel) Delete() {
}
delete(c.store.byName, c.name)
c.store.world.RemoveObject(c.id)
+
+ deleted := Tombstone {c.name}
+ c.store.deleted[c.id] = deleted
+ c.store.world.PutObject(c.id, deleted)
}
func (c *Channel) GetInfo() proto.Object {
@@ -146,3 +157,9 @@ func (c *Channel) GetInfo() proto.Object {
"channel", c.id, map[string]string {"": c.name},
}
}
+
+func (t Tombstone) GetInfo() proto.Object {
+ return proto.Object {
+ "deleted", "", map[string]string {"": t.name},
+ }
+}
diff --git a/server/channel/command.go b/server/channel/command.go
index 94cf38f..5190efe 100644
--- a/server/channel/command.go
+++ b/server/channel/command.go
@@ -251,3 +251,20 @@ func (c *Channel) SendRequest(r session.Request) {
r.ReplyInvalid()
}
}
+
+func (t Tombstone) SendRequest(r session.Request) {
+ switch r.Cmd.Kind {
+
+ case "update":
+ r.Reply(proto.Fail{"bad-target", "", nil}.Cmd())
+
+ case "i", "s":
+ r.Reply(proto.NewCmd("i", "", t.GetInfo()))
+
+ case "u":
+ r.ReplyOk()
+
+ default:
+ r.ReplyInvalid()
+ }
+}