function for initially publishing a post
This commit is contained in:
		
							parent
							
								
									bf277c5a73
								
							
						
					
					
						commit
						4339cace20
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		|  | @ -19,6 +19,7 @@ import           Control.Exception             (Exception (..), try) | ||||||
| import           Control.Monad                 (foldM, forM, forM_, forever) | import           Control.Monad                 (foldM, forM, forM_, forever) | ||||||
| import           Control.Monad.IO.Class        (liftIO) | import           Control.Monad.IO.Class        (liftIO) | ||||||
| import           Control.Monad.STM | import           Control.Monad.STM | ||||||
|  | import           Data.Bifunctor | ||||||
| import qualified Data.ByteString.Lazy.UTF8     as BSUL | import qualified Data.ByteString.Lazy.UTF8     as BSUL | ||||||
| import qualified Data.ByteString.UTF8          as BSU | import qualified Data.ByteString.UTF8          as BSU | ||||||
| import qualified Data.HashMap.Strict           as HMap | import qualified Data.HashMap.Strict           as HMap | ||||||
|  | @ -409,6 +410,20 @@ clientUnsubscribeFrom serv tag = do | ||||||
|           lookupResponse |           lookupResponse | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | -- | publish a new post to the inbox of a specified relay instance. This | ||||||
|  | -- instance will then be the originating instance of the post and will forward | ||||||
|  | -- the post to the responsible relays. | ||||||
|  | -- As the initial publishing isn't done by a specific relay (but *to* a specific relay | ||||||
|  | -- instead), the function does *not* take a PostService as argument. | ||||||
|  | clientPublishPost :: HTTP.Manager   -- for better performance, a shared HTTP manager has to be provided | ||||||
|  |                   -> String         -- hostname | ||||||
|  |                   -> Int            -- port | ||||||
|  |                   -> PostContent    -- post content | ||||||
|  |                   -> IO (Either String ())  -- error or success | ||||||
|  | clientPublishPost httpman hostname port postC = do | ||||||
|  |     resp <- runClientM (postInboxClient postC) (mkClientEnv httpman (BaseUrl Http hostname port "")) | ||||||
|  |     pure . bimap show (const ()) $ resp | ||||||
|  | 
 | ||||||
| -- currently this is unused code | -- currently this is unused code | ||||||
| getClients :: String -> Int -> HTTP.Manager -> Client IO PostServiceAPI | getClients :: String -> Int -> HTTP.Manager -> Client IO PostServiceAPI | ||||||
| getClients hostname' port' httpMan = hoistClient clientAPI | getClients hostname' port' httpMan = hoistClient clientAPI | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue