mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 18:24:51 +09:00
S2S: sharerCreateTicketF: Tweak to use the new utils
This commit is contained in:
parent
1a8ecb5995
commit
e46bcac559
1 changed files with 7 additions and 20 deletions
|
@ -454,13 +454,16 @@ sharerCreateTicketF
|
|||
-> ExceptT Text Handler Text
|
||||
sharerCreateTicketF now shrRecip author body mfwd luCreate ticket muTarget = do
|
||||
(targetAndContext, _, _) <- checkCreateTicket author ticket muTarget
|
||||
runDBExcept $ do
|
||||
mractid <- runDBExcept $ do
|
||||
ibidRecip <- lift $ do
|
||||
sid <- getKeyBy404 $ UniqueSharer shrRecip
|
||||
p <- getValBy404 $ UniquePersonIdent sid
|
||||
return $ personInbox p
|
||||
personInbox <$> getValBy404 (UniquePersonIdent sid)
|
||||
checkTargetAndContextDB targetAndContext
|
||||
lift $ insertToInbox luCreate ibidRecip
|
||||
lift $ insertToInbox now author body ibidRecip luCreate True
|
||||
return $
|
||||
case mractid of
|
||||
Nothing -> "Activity already exists in my inbox"
|
||||
Just _ -> "Activity inserted to my inbox"
|
||||
where
|
||||
checkTargetAndContextDB (Left (_, shr, prj)) = do
|
||||
mj <- lift $ runMaybeT $ do
|
||||
|
@ -469,22 +472,6 @@ sharerCreateTicketF now shrRecip author body mfwd luCreate ticket muTarget = do
|
|||
unless (isJust mj) $ throwE "Local context: No such project"
|
||||
checkTargetAndContextDB (Right _) = return ()
|
||||
|
||||
insertToInbox luAct ibidRecip = do
|
||||
let iidAuthor = remoteAuthorInstance author
|
||||
roid <-
|
||||
either entityKey id <$> insertBy' (RemoteObject iidAuthor luAct)
|
||||
let jsonObj = persistJSONFromBL $ actbBL body
|
||||
ract = RemoteActivity roid jsonObj now
|
||||
ractid <- either entityKey id <$> insertBy' ract
|
||||
ibiid <- insert $ InboxItem True
|
||||
mibrid <- insertUnique $ InboxItemRemote ibidRecip ractid ibiid
|
||||
let recip = shr2text shrRecip
|
||||
case mibrid of
|
||||
Nothing -> do
|
||||
delete ibiid
|
||||
return $ "Activity already exists in inbox of /s/" <> recip
|
||||
Just _ -> return $ "Activity inserted to inbox of /s/" <> recip
|
||||
|
||||
projectCreateTicketF
|
||||
:: UTCTime
|
||||
-> ShrIdent
|
||||
|
|
Loading…
Reference in a new issue