From d66beb95e5543959dc2c8cd8f2610da803f4fdec Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Thu, 11 Jan 2024 10:02:27 -0800 Subject: [PATCH] Update APIs, Formatting --- app/plugins/contactRetry_test.go | 8 ++++---- peer/cwtch_peer.go | 31 ++++++++++++++++++++----------- peer/profile_interface.go | 4 +++- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app/plugins/contactRetry_test.go b/app/plugins/contactRetry_test.go index 3ec0fc7..edd6676 100644 --- a/app/plugins/contactRetry_test.go +++ b/app/plugins/contactRetry_test.go @@ -37,10 +37,10 @@ func TestContactRetryQueue(t *testing.T) { setup := false for !setup { if _, exists := cr.connections.Load(testOnion); exists { - if _, exists := cr.authorizedPeers.Load(testOnion); exists { - t.Logf("authorized") - setup = true - } + if _, exists := cr.authorizedPeers.Load(testOnion); exists { + t.Logf("authorized") + setup = true + } } } diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index d28734a..b0dd928 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -718,17 +718,8 @@ func (cp *cwtchPeer) UpdateConversationAccessControlList(id int, acl model.Acces return cp.storage.SetConversationACL(id, acl) } -// EnhancedGetConversationAccessControlList serialzies the access control list associated with the conversation -func (cp *cwtchPeer) EnhancedGetConversationAccessControlList(id int) (string, error) { - ci, err := cp.GetConversationInfo(id) - if err == nil { - return string(ci.ACL.Serialize()), nil - } - return "", err -} - -// UpdateConversationAccessControlListJSON wraps UpdateConversationAccessControlList and allows updating via a serialized JSON struct -func (cp *cwtchPeer) UpdateConversationAccessControlListJSON(id int, json string) error { +// EnhancedUpdateConversationAccessControlList wraps UpdateConversationAccessControlList and allows updating via a serialized JSON struct +func (cp *cwtchPeer) EnhancedUpdateConversationAccessControlList(id int, json string) error { _, err := cp.GetConversationInfo(id) if err == nil { acl, err := model.DeserializeAccessControlList([]byte(json)) @@ -740,6 +731,24 @@ func (cp *cwtchPeer) UpdateConversationAccessControlListJSON(id int, json string return err } +// GetConversationAccessControlList returns the access control list associated with the conversation +func (cp *cwtchPeer) GetConversationAccessControlList(id int) (model.AccessControlList, error) { + ci, err := cp.GetConversationInfo(id) + if err == nil { + return ci.ACL, nil + } + return nil, err +} + +// EnhancedGetConversationAccessControlList serialzies the access control list associated with the conversation +func (cp *cwtchPeer) EnhancedGetConversationAccessControlList(id int) (string, error) { + ci, err := cp.GetConversationInfo(id) + if err == nil { + return string(ci.ACL.Serialize()), nil + } + return "", err +} + // AcceptConversation looks up a conversation by `handle` and sets the Accepted status to `true` // This will cause Cwtch to auto connect to this conversation on start up func (cp *cwtchPeer) AcceptConversation(id int) error { diff --git a/peer/profile_interface.go b/peer/profile_interface.go index 444ceb6..9675d5a 100644 --- a/peer/profile_interface.go +++ b/peer/profile_interface.go @@ -123,8 +123,10 @@ type CwtchPeer interface { // API-level management of conversation access control UpdateConversationAccessControlList(id int, acl model.AccessControlList) error + EnhancedUpdateConversationAccessControlList(conversation int, acjson string) error + + GetConversationAccessControlList(conversation int) (model.AccessControlList, error) EnhancedGetConversationAccessControlList(conversation int) (string, error) - UpdateConversationAccessControlListJSON(conversation int, acjson string) error // Convieniance Functions for ACL Management AcceptConversation(conversation int) error