summaryrefslogtreecommitdiff
path: root/server/object/tombstone.go
blob: 05d9600e1db478e558216af256319b17ebbad1e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package object

import (
	"citrons.xyz/talk/proto"
	"citrons.xyz/talk/server/session"
)

type Tombstone struct {
	Id string
	Fields map[string]string
}

func (t Tombstone) InfoFor(uid string) proto.Object {
	return proto.Object {"gone", t.Id, t.Fields}
}

func (t Tombstone) SendRequest(r session.Request) {
	switch r.Cmd.Kind {

	case "i", "s":
		r.Reply(proto.NewCmd("i", "", t.InfoFor(r.From.UserId)))

	case "u":
		r.ReplyOk()

	default:
		r.Reply(proto.Fail{"bad-target", "", nil}.Cmd())
	}
}