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