From 86e7001ae421e47f089cadc84676f103524270d7 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 3 Apr 2023 11:19:45 -0700 Subject: [PATCH] Support Profile Attributes --- templates/lib_template.go | 8 +++++++- utils/eventHandler.go | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/lib_template.go b/templates/lib_template.go index f5cbed1..81b63c2 100644 --- a/templates/lib_template.go +++ b/templates/lib_template.go @@ -288,10 +288,16 @@ func SetProfileAttribute(profileOnion string, key string, value string) { if profile != nil { 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. if zone == attr.ProfileZone && key == constants.Name { 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 { profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.PeerAutostart, value) } else { diff --git a/utils/eventHandler.go b/utils/eventHandler.go index ddab3db..a94c715 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -390,7 +390,6 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string { 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 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 if cxnState == connections.AUTHENTICATED { // 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: