Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverloadedStrings #-}
- {-# LANGUAGE ScopedTypeVariables #-}
- {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
- module DebugMain where
- import System.IO.Unsafe (unsafePerformIO)
- import Vertigo.Config (getConfig)
- import Vertigo.Config.Auth (AuthToken, authenticateUser, createToken)
- import Vertigo.Config.SQS (sendSQS, NotifyMode (..))
- import Vertigo.Config.Types (Config)
- import Vertigo.Monad (Vertigo, runApp)
- import Vertigo.Types.Activity (ActivityTags (..))
- import Vertigo.Types.Content (ContentId (..))
- import Vertigo.Types.Feed (FeedItem (..))
- import Vertigo.Types.HashTag (HashTags (..))
- import Vertigo.Types.Mention (MentionTag (..), MentionTags (..))
- import Vertigo.Types.Mood (MoodTags (..))
- import Vertigo.Types.Post (BroadcastTitle (..), IsRepost (..), Post (..),
- PostDeleted (..), PostDescription (..), PostId (..),
- PostType (AlbumType), Reposts (..))
- import Vertigo.Types.TimeStamp (TimeStamp (..))
- import Vertigo.Types.User (UserId (..))
- --import Vertigo.Types.VUUID (VUUID (..))
- import Vertigo.Worker (pollAndDispatch)
- import qualified Aws.Sqs as Sqs
- --import qualified Data.Aeson as A
- --dynamoGet ::
- -- (FromDynItem b, Log.Logging m, MonadIO m, MonadReader Config m,
- -- MonadError Error m, MonadBaseControl IO m) =>
- -- GetItem -> m b
- kick :: IO ()
- kick = do
- -- let pid = PostId "1834df6f-87b7-4e5e-9834-df6f87b76e5e"
- -- (post :: Post) <- runHere config $ dynamoGet (getPost pid)
- print post
- -- (FeedItem,Post,NotifyMode, AuthToken, Bool)
- let msg = (feedItem, post, notifyMode, token uid, True)
- print msg
- rs <- runHere $ sendSQS msg [("DataType", Sqs.UserMessageAttributeString Nothing "FeedItem")]
- print rs
- runHere pollAndDispatch
- uid :: UserId
- uid = UserId "263d83ba-78cd-4583-b86d-b8d53a3fd619"
- {-# NOINLINE token #-}
- token :: UserId -> AuthToken
- token uid = unsafePerformIO $ runHere $ do
- t <- createToken uid
- authenticateUser $ Just t
- {-# NOINLINE config #-}
- config :: Config
- config = forceEither $ unsafePerformIO getConfig
- runHere :: Vertigo m -> IO m
- runHere op = do
- x <- runApp config op
- case x of
- Left err -> error $ show err
- Right r -> return r
- notifyMode :: NotifyMode
- notifyMode = WithNotifications
- feedItem :: FeedItem
- feedItem = FeedItem
- { feedItemId = ContentId "1834df6f-87b7-4e5e-9834-df6f87b76e5e"
- , feedItemUserId = UserId "263d83ba-78cd-4583-b86d-b8d53a3fd619"
- }
- post :: Post
- post = Post
- { postPostId = PostId "1834df6f-87b7-4e5e-9834-df6f87b76e5e"
- , postAuthorId = UserId "263d83ba-78cd-4583-b86d-b8d53a3fd619"
- , postIsRepost = IsRepost False
- , postOriginalPostId = Nothing
- , postContentId = ContentId "d2ea4185-ab19-4323-989e-8d7688f86853"
- , postTimestamp = TimeStamp 1490840802667674
- , postContentType = AlbumType
- , postDescription = Just (PostDescription "@justin this is a test")
- , postRepostDescription = Nothing
- , postDeleted = PostDeleted False
- , postRepostCount = Reposts 0
- , postHashes = HashTags []
- , postMentions = MentionTags [MentionTag "justin"]
- , postMoods = MoodTags []
- , postActivities = ActivityTags []
- , postBroadcastTitle = Just (BroadcastTitle "Broadcast Title!")
- }
- {- | Pulls a "Right" value out of an Either value. If the Either value is
- Left, raises an exception with "error". -}
- forceEither :: Show e => Either e a -> a
- forceEither (Left x) = error (show x)
- forceEither (Right x) = x
- weirdParse :: String -> (String, String)
- weirdParse [] = ([],[])
- weirdParse (x:y:zs) = let (xs, ys) = weirdParse zs in (x:xs, y:ys)
- weirdParse [x] = ([x], [])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement