oc-peer partnership flow improved
This commit is contained in:
@@ -55,10 +55,6 @@ func ListenNATS() {
|
||||
if resp.FromApp == config.GetAppName() || resp.Datatype != tools.PEER {
|
||||
return
|
||||
}
|
||||
m := map[string]interface{}{
|
||||
"verify": true,
|
||||
"relation": peer.PENDING_PARTNER,
|
||||
}
|
||||
p := &peer.Peer{}
|
||||
if err := json.Unmarshal(resp.Payload, &p); err == nil {
|
||||
/*if err := verify(resp.Payload); err != nil {
|
||||
@@ -68,22 +64,25 @@ func ListenNATS() {
|
||||
|
||||
access := oclib.NewRequestAdmin(oclib.LibDataEnum(resp.Datatype), nil)
|
||||
if data := access.LoadOne(p.GetID()); data.Data != nil {
|
||||
if !data.ToPeer().Verify && data.ToPeer().Relation == peer.PENDING_PARTNER {
|
||||
if p.Relation == peer.PENDING_PARTNER {
|
||||
if data.ToPeer().Verify {
|
||||
access.UpdateOne(map[string]interface{}{
|
||||
"verify": false,
|
||||
"relation": peer.PARTNER,
|
||||
}, p.GetID())
|
||||
} else if data.ToPeer().Relation != peer.BLACKLIST && data.ToPeer().Relation != peer.SELF {
|
||||
if p.Relation == peer.NONE {
|
||||
access.UpdateOne(map[string]interface{}{
|
||||
"relation": peer.NONE,
|
||||
}, p.GetID())
|
||||
} else {
|
||||
access.UpdateOne(m, p.GetID())
|
||||
access.UpdateOne(map[string]interface{}{
|
||||
"verify": true,
|
||||
"relation": peer.PENDING_PARTNER,
|
||||
}, p.GetID())
|
||||
}
|
||||
} else if data.ToPeer().Relation != peer.BLACKLIST && data.ToPeer().Relation != peer.SELF {
|
||||
access.UpdateOne(map[string]interface{}{
|
||||
"relation": p.Relation,
|
||||
}, p.GetID())
|
||||
}
|
||||
} else if err := json.Unmarshal(resp.Payload, &m); err == nil {
|
||||
access.StoreOne(m)
|
||||
} else if p.Relation != peer.SELF {
|
||||
access.StoreOne(p.Serialize(p))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user