~singpolyma/cheogram

f3f1f4fa49e4b5510069db6db69928b7ceee1720 — Stephen Paul Weber 3 years ago f95e35e
Store both direction on ownership

And allow multiple JIDs to own the same cheoJid
1 files changed, 7 insertions(+), 1 deletions(-)

M Main.hs
M Main.hs => Main.hs +7 -1
@@ 947,7 947,13 @@ component db backendHost toRoomPresences toRejoinManager toJoinPartDebouncer toC
						case (fmap (first parseJID) (readZ =<< maybeToken), parseJID $ unescapeJid localpart) of
							(Just (Just cheoJid, token), Just owner) | (s"CHEOGRAM"++token) == txt -> do
								log "SET OWNER" (cheoJid, owner)
								tcPutJID db cheoJid "owner" owner

								True <- TC.runTCM (TC.put db (T.unpack (bareTxt owner) ++ "\0cheoJid") (T.unpack $ formatJID cheoJid))

								owners <- (fromMaybe [] . (readZ =<<)) <$>
									maybe (return Nothing) (TC.runTCM . TC.get db) (tcKey cheoJid "owners")
								tcPut db cheoJid "owners" (show $ (T.unpack $ bareTxt owner) : owners)

							_ -> log "NO TOKEN FOUND, or mismatch" maybeToken
			(Just from, Just to, Nothing, Just localpart, _)
				| fmap (((s"CHEOGRAM%") `T.isPrefixOf`) . strResource) (jidResource to) /= Just True -> do