add get[Profile|Conversation]Attribute api #81

Merged
dan merged 1 commits from getAttr into trunk 2022-04-05 00:48:55 +00:00
Owner
No description provided.
sarah reviewed 2022-04-04 16:50:38 +00:00
lib.go Outdated
@ -1028,6 +1028,42 @@ func SetProfileAttribute(profileOnion string, key string, value string) {
}
}
type Attribute struct {

document

document
dan marked this conversation as resolved
lib.go Outdated
@ -1046,0 +1086,4 @@
return C.CString(GetConversationAttribute(profileOnion, int(conversation_id), key))
}
// GetGonversationAttribute provides a wrapper around profile.GetProfileAttribute

comment is wrong

comment is wrong
dan marked this conversation as resolved
lib.go Outdated
@ -1046,0 +1091,4 @@
func GetConversationAttribute(profileOnion string, conversationID int, key string) string {
profile := application.GetPeer(profileOnion)
zone, key := attr.ParseZone(key)
res, exists := profile.GetConversationAttribute(conversationID, attr.LocalScope.ConstructScopedZonedPath(zone.ConstructZonedPath(key)))

this will only get local attributes - some conversation attributes are non-local...probably worth using attr.ParseScope to fully resolve all possible keys.

this will only get local attributes - some conversation attributes are non-local...probably worth using attr.ParseScope to fully resolve all possible keys.
lib.go Outdated
@ -1046,0 +1092,4 @@
profile := application.GetPeer(profileOnion)
zone, key := attr.ParseZone(key)
res, exists := profile.GetConversationAttribute(conversationID, attr.LocalScope.ConstructScopedZonedPath(zone.ConstructZonedPath(key)))
attr := Attribute{exists == nil, res}

exists is bool right? checking for nil seems wrong here. Use named parameters (Attribute {Exists: x...

exists is bool right? checking for nil seems wrong here. Use named parameters (`Attribute {Exists: x...`
Author
Owner

my bad, renamed to err, as this function returns an err, not a bool, hence the nil check

my bad, renamed to err, as this function returns an err, not a bool, hence the nil check
dan marked this conversation as resolved
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/libcwtch-go/262
dan force-pushed getAttr from 296146fa2b to cfd8fe21c8 2022-04-05 00:23:04 +00:00 Compare
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/libcwtch-go/264
sarah approved these changes 2022-04-05 00:46:02 +00:00
dan merged commit 3ad0bc904c into trunk 2022-04-05 00:48:55 +00:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Label
No Milestone
No Assignees
3 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/libcwtch-go#81
No description provided.