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
/
problem_report_impl.go
86 lines (67 loc) · 2.02 KB
/
problem_report_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
81
82
83
84
85
86
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"
)
var ProblemReportCreator = &ProblemReportFactor{}
type ProblemReportFactor struct{}
func (f *ProblemReportFactor) NewMsg(init didcomm.MsgInit) didcomm.MessageHdr {
m := &ProblemReport{
Type: init.Type,
ID: init.AID,
Description: Code{Code: init.Info},
Thread: decorator.CheckThread(init.Thread, init.AID),
}
return NewProblemReport(m)
}
func (f *ProblemReportFactor) NewMessage(data []byte) didcomm.MessageHdr {
return NewProblemReportMsg(data)
}
func init() {
gob.Register(&ProblemReportImpl{})
aries.Creator.Add(pltype.NotificationProblemReport, ProblemReportCreator)
aries.Creator.Add(pltype.DIDOrgNotificationProblemReport, ProblemReportCreator)
}
func NewProblemReport(r *ProblemReport) *ProblemReportImpl {
return &ProblemReportImpl{ProblemReport: r}
}
func NewProblemReportMsg(data []byte) *ProblemReportImpl {
var mImpl ProblemReportImpl
dto.FromJSON(data, &mImpl)
mImpl.checkThread()
return &mImpl
}
// MARK: Helpers
func (p *ProblemReportImpl) checkThread() {
p.ProblemReport.Thread = decorator.CheckThread(p.ProblemReport.Thread, p.ProblemReport.ID)
}
// MARK: Struct
type ProblemReportImpl struct {
*ProblemReport
}
func (p *ProblemReportImpl) ID() string {
return p.ProblemReport.ID
}
func (p *ProblemReportImpl) Type() string {
return p.ProblemReport.Type
}
func (p *ProblemReportImpl) SetID(id string) {
p.ProblemReport.ID = id
}
func (p *ProblemReportImpl) SetType(t string) {
p.ProblemReport.Type = t
}
func (p *ProblemReportImpl) JSON() []byte {
return dto.ToJSONBytes(p)
}
func (p *ProblemReportImpl) Thread() *decorator.Thread {
//if p.ProblemReport.Thread == nil {}
return p.ProblemReport.Thread
}
func (p *ProblemReportImpl) FieldObj() interface{} {
return p.ProblemReport
}