summaryrefslogtreecommitdiff
path: root/server/object/tombstone.go
blob: a2872f6a8f96161454fcd74b582d0f7ba78a0c3c (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
30
31
32
33
34
35
36
37
38
39
package object

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

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

type TombstoneKind struct {}

func (t TombstoneKind) Undata(o proto.Object) Object {
	return Tombstone {Id: o.Id, Fields: o.Fields}
}

func (t Tombstone) InfoFor(uid string) proto.Object {
	return t.Data()
}

func (t Tombstone) Data() 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())
	}
}