forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_app.go
34 lines (26 loc) · 1.04 KB
/
api_app.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
package bertyprotocol
import (
"context"
"berty.tech/berty/v2/go/pkg/errcode"
"berty.tech/berty/v2/go/pkg/protocoltypes"
)
func (s *service) AppMetadataSend(ctx context.Context, req *protocoltypes.AppMetadataSend_Request) (*protocoltypes.AppMetadataSend_Reply, error) {
g, err := s.getContextGroupForID(req.GroupPK)
if err != nil {
return nil, errcode.ErrGroupMissing.Wrap(err)
}
if _, err := g.MetadataStore().SendAppMetadata(ctx, req.Payload, req.GetAttachmentCIDs()); err != nil {
return nil, errcode.ErrOrbitDBAppend.Wrap(err)
}
return &protocoltypes.AppMetadataSend_Reply{}, nil
}
func (s *service) AppMessageSend(ctx context.Context, req *protocoltypes.AppMessageSend_Request) (*protocoltypes.AppMessageSend_Reply, error) {
g, err := s.getContextGroupForID(req.GroupPK)
if err != nil {
return nil, errcode.ErrGroupMissing.Wrap(err)
}
if _, err := g.MessageStore().AddMessage(ctx, req.Payload, req.GetAttachmentCIDs()); err != nil {
return nil, errcode.ErrOrbitDBAppend.Wrap(err)
}
return &protocoltypes.AppMessageSend_Reply{}, nil
}