This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
forward_impl.go
80 lines (63 loc) · 1.57 KB
/
forward_impl.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package common
import (
"encoding/gob"
"github.com/findy-network/findy-agent/agent/aries"
"github.com/findy-network/findy-agent/agent/didcomm"
"github.com/findy-network/findy-agent/agent/pltype"
"github.com/findy-network/findy-agent/std/decorator"
"github.com/findy-network/findy-common-go/dto"
"github.com/lainio/err2/assert"
)
var forwardCreator = &forwardFactor{}
type forwardFactor struct{}
func (f *forwardFactor) NewMsg(init didcomm.MsgInit) didcomm.MessageHdr {
m := &Forward{
Type: init.Type,
ID: init.AID,
To: init.To,
Msg: init.Msg,
}
return newForward(m)
}
func (f *forwardFactor) NewMessage(data []byte) didcomm.MessageHdr {
return newForwardMsg(data)
}
func init() {
gob.Register(&forwardImpl{})
aries.Creator.Add(pltype.RoutingForward, forwardCreator)
aries.Creator.Add(pltype.DIDOrgRoutingForward, forwardCreator)
}
func newForward(r *Forward) *forwardImpl {
return &forwardImpl{Forward: r}
}
func newForwardMsg(data []byte) *forwardImpl {
var mImpl forwardImpl
dto.FromJSON(data, &mImpl)
return &mImpl
}
// MARK: Struct
type forwardImpl struct {
*Forward
}
func (p *forwardImpl) ID() string {
return p.Forward.ID
}
func (p *forwardImpl) Type() string {
return p.Forward.Type
}
func (p *forwardImpl) SetID(id string) {
p.Forward.ID = id
}
func (p *forwardImpl) SetType(t string) {
p.Forward.Type = t
}
func (p *forwardImpl) JSON() []byte {
return dto.ToJSONBytes(p)
}
func (p *forwardImpl) Thread() *decorator.Thread {
assert.That(false, "Should not be here")
return nil
}
func (p *forwardImpl) FieldObj() interface{} {
return p.Forward
}