forked from CyCoreSystems/ari-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailbox.go
53 lines (43 loc) · 1.15 KB
/
mailbox.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package server
import (
"context"
"github.com/CyCoreSystems/ari-proxy/v5/proxy"
)
func (s *Server) mailboxData(ctx context.Context, reply string, req *proxy.Request) {
data, err := s.ari.Mailbox().Data(req.Key)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Mailbox: data,
},
})
}
func (s *Server) mailboxGet(ctx context.Context, reply string, req *proxy.Request) {
data, err := s.ari.Mailbox().Data(req.Key)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Key: data.Key,
})
}
func (s *Server) mailboxDelete(ctx context.Context, reply string, req *proxy.Request) {
s.sendError(reply, s.ari.Mailbox().Delete(req.Key))
}
func (s *Server) mailboxList(ctx context.Context, reply string, req *proxy.Request) {
list, err := s.ari.Mailbox().List(nil)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Keys: list,
})
}
func (s *Server) mailboxUpdate(ctx context.Context, reply string, req *proxy.Request) {
s.sendError(reply, s.ari.Mailbox().Update(req.Key, req.MailboxUpdate.Old, req.MailboxUpdate.New))
}