bugfix: subscribe as default if not subscribed yet, when posting to a tag

This commit is contained in:
Trolli Schmittlauch 2020-09-10 13:09:28 +02:00
parent 3c76544afb
commit 3ac89d301c

View file

@ -611,6 +611,7 @@ launchWorkerThreads serv = concurrently_
(fetchTagPosts serv) (fetchTagPosts serv)
(relayWorker serv) (relayWorker serv)
-- | process the pending relay inbox of incoming posts from the internal queue: -- | process the pending relay inbox of incoming posts from the internal queue:
-- Look up responsible relay node for given hashtag and forward post to it -- Look up responsible relay node for given hashtag and forward post to it
processIncomingPosts :: DHT d => PostService d -> IO () processIncomingPosts :: DHT d => PostService d -> IO ()
@ -642,7 +643,7 @@ processIncomingPosts serv = forever $ do
now <- getPOSIXTime now <- getPOSIXTime
subscriptionStatus <- HMap.lookup (hashtagToId tag) <$> readTVarIO (ownSubscriptions serv) subscriptionStatus <- HMap.lookup (hashtagToId tag) <$> readTVarIO (ownSubscriptions serv)
-- if not yet subscribed or subscription expires within 2 minutes, (re)subscribe to tag -- if not yet subscribed or subscription expires within 2 minutes, (re)subscribe to tag
when (maybe False (\subLease -> now - subLease < 120) subscriptionStatus) $ when (maybe True (\subLease -> now - subLease < 120) subscriptionStatus) $
void $ clientSubscribeTo serv tag void $ clientSubscribeTo serv tag
-- for evaluation, return the tag of the successfully forwarded post -- for evaluation, return the tag of the successfully forwarded post