Support Profile Attributes
This commit is contained in:
parent
e5e4084fae
commit
86e7001ae4
|
@ -288,10 +288,16 @@ func SetProfileAttribute(profileOnion string, key string, value string) {
|
||||||
if profile != nil {
|
if profile != nil {
|
||||||
zone, key := attr.ParseZone(key)
|
zone, key := attr.ParseZone(key)
|
||||||
|
|
||||||
// TODO We only allow public.profile.key to be set for now.
|
// TODO We only allow certain public.profile.key to be set for now.
|
||||||
// All other scopes and zones need to be added explicitly or handled by Cwtch.
|
// All other scopes and zones need to be added explicitly or handled by Cwtch.
|
||||||
if zone == attr.ProfileZone && key == constants.Name {
|
if zone == attr.ProfileZone && key == constants.Name {
|
||||||
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, value)
|
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, value)
|
||||||
|
} else if zone == attr.ProfileZone && key == constants.ProfileAttribute1 {
|
||||||
|
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.ProfileAttribute1, value)
|
||||||
|
} else if zone == attr.ProfileZone && key == constants.ProfileAttribute2 {
|
||||||
|
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.ProfileAttribute2, value)
|
||||||
|
} else if zone == attr.ProfileZone && key == constants.ProfileAttribute3 {
|
||||||
|
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.ProfileAttribute3, value)
|
||||||
} else if zone == attr.ProfileZone && key == constants.PeerAutostart {
|
} else if zone == attr.ProfileZone && key == constants.PeerAutostart {
|
||||||
profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.PeerAutostart, value)
|
profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.PeerAutostart, value)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -390,7 +390,6 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
ev.Event.Data["Nick"] = ev.Event.Data["RemotePeer"]
|
ev.Event.Data["Nick"] = ev.Event.Data["RemotePeer"]
|
||||||
// If we dont have a name val for a peer, but they have sent us a message, we might be approved now, re-ask
|
// If we dont have a name val for a peer, but they have sent us a message, we might be approved now, re-ask
|
||||||
profile.SendScopedZonedGetValToContact(ci.ID, attr.PublicScope, attr.ProfileZone, constants.Name)
|
profile.SendScopedZonedGetValToContact(ci.ID, attr.PublicScope, attr.ProfileZone, constants.Name)
|
||||||
profile.SendScopedZonedGetValToContact(ci.ID, attr.PublicScope, attr.ProfileZone, constants.CustomProfileImageKey)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +519,7 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
// No enrichment needed
|
// No enrichment needed
|
||||||
if cxnState == connections.AUTHENTICATED {
|
if cxnState == connections.AUTHENTICATED {
|
||||||
// if known and authed, get vars
|
// if known and authed, get vars
|
||||||
profile.SendScopedZonedGetValToContact(contact.ID, attr.PublicScope, attr.ProfileZone, constants.Name)
|
|
||||||
profile.SendScopedZonedGetValToContact(contact.ID, attr.PublicScope, attr.ProfileZone, constants.CustomProfileImageKey)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case event.ServerStateChange:
|
case event.ServerStateChange:
|
||||||
|
|
Loading…
Reference in New Issue