summaryrefslogtreecommitdiff
path: root/src/Contact.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-01-08 23:05:43 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-01-08 23:05:43 +0100
commit26c03fae3e49057ac18462c5d1f48b9b221e1dcc (patch)
tree3a6b2c8964d132427f9adaabb727f447a5c9411c /src/Contact.hs
parenta03ddf116287609057f8372a019ca3d254e14207 (diff)
Contact custom name setting support and test
Diffstat (limited to 'src/Contact.hs')
-rw-r--r--src/Contact.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Contact.hs b/src/Contact.hs
index 4e2cb17..6585985 100644
--- a/src/Contact.hs
+++ b/src/Contact.hs
@@ -4,6 +4,8 @@ module Contact (
contactCustomName,
contactName,
+ contactSetName,
+
ContactService,
contactRequest,
contactAccept,
@@ -79,6 +81,16 @@ contactName c = fromJust $ msum
, Just T.empty
]
+contactSetName :: MonadHead LocalState m => Contact -> Text -> Set Contact -> m (Set Contact)
+contactSetName contact name set = do
+ st <- getStorage
+ cdata <- wrappedStore st ContactData
+ { cdPrev = toComponents contact
+ , cdIdentity = []
+ , cdName = Just name
+ }
+ storeSetAdd st (mergeSorted @Contact [cdata]) set
+
type ContactService = PairingService ContactAccepted