~singpolyma/cheogram

08c3319c0766343cf0f08aa30b3deff7a44aecf2 — Stephen Paul Weber 4 years ago 4583d56
Process even if it already exists
1 files changed, 2 insertions(+), 5 deletions(-)

M Main.hs
M Main.hs => Main.hs +2 -5
@@ 1088,13 1088,10 @@ component db redis backendHost toRoomPresences toRejoinManager toJoinPartDebounc
					priority = fromMaybe 0 $ (readZ . textToString . mconcat =<< elementText <$> child (s"{jabber:component:accept}priority") p)
					pavailableness = availableness show priority
				in do
				-- We already know about this one?
				exists <- fmap (fromMaybe False . hush) $ Redis.runRedis redis $ Redis.hexists (encodeUtf8 $ bareTxt from) (encodeUtf8 $ maybe mempty strResource $ jidResource from)
				-- Caps?
				case (exists, XML.attributeText (s"ver") =<< caps, XML.attributeText (s"node") =<< caps) of
					(True, _, _) -> log "IGNOREAVAIL" from
				case (XML.attributeText (s"ver") =<< caps, XML.attributeText (s"node") =<< caps) of
				-- Yes: write ver to <barejid>/resource and <cheoagramjid>/resource
					(_, Just ver, Just node) -> do
					(Just ver, Just node) -> do
						let bver = Base64.decodeLenient $ encodeUtf8 ver
						let val = LZ.toStrict $ Builder.toLazyByteString (Builder.word16BE pavailableness ++ Builder.byteString bver)
						Right exists <- Redis.runRedis redis $ do