1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 02:14:52 +09:00

S2S: repoCreateTicketF: Store a Patch record in DB, to have a local copy

This commit is contained in:
fr33domlover 2020-07-21 10:03:51 +00:00
parent 029fce58a4
commit fd8405e741

View file

@ -788,7 +788,7 @@ insertRemoteTicket
-> TextPandocMarkdown -> TextPandocMarkdown
-> RemoteActivityId -> RemoteActivityId
-> OutboxItemId -> OutboxItemId
-> ReaderT SqlBackend m (Either Bool ()) -> ReaderT SqlBackend m (Either Bool TicketId)
insertRemoteTicket mktxl author luTicket published summary content source ractidCreate obiidAccept = do insertRemoteTicket mktxl author luTicket published summary content source ractidCreate obiidAccept = do
tid <- insert Ticket tid <- insert Ticket
{ ticketNumber = Nothing { ticketNumber = Nothing
@ -840,7 +840,7 @@ insertRemoteTicket mktxl author luTicket published summary content source ractid
delete tclid delete tclid
delete tid delete tid
return $ Left True return $ Left True
Just _rtid -> return $ Right () Just _rtid -> return $ Right tid
insertAcceptOnCreate collections outboxItemRoute actorRoute author luCreate tlocal obiidAccept = do insertAcceptOnCreate collections outboxItemRoute actorRoute author luCreate tlocal obiidAccept = do
encodeRouteLocal <- getEncodeRouteLocal encodeRouteLocal <- getEncodeRouteLocal
@ -919,7 +919,7 @@ projectCreateTicketF now shrRecip prjRecip author body mfwd luCreate ticket muTa
let makeTPL tclid = TicketProjectLocal tclid jid let makeTPL tclid = TicketProjectLocal tclid jid
result <- insertRemoteTicket makeTPL author (AP.ticketId tlocal) published title desc src ractid obiidAccept result <- insertRemoteTicket makeTPL author (AP.ticketId tlocal) published title desc src ractid obiidAccept
unless (isRight result) $ delete obiidAccept unless (isRight result) $ delete obiidAccept
for result $ \ () -> do for result $ \ _tid -> do
mremotesHttpFwd <- for mfwd $ \ (localRecips, sig) -> do mremotesHttpFwd <- for mfwd $ \ (localRecips, sig) -> do
let sieve = let sieve =
makeRecipientSet makeRecipientSet
@ -982,7 +982,7 @@ repoCreateTicketF
repoCreateTicketF now shrRecip rpRecip author body mfwd luCreate ticket muTarget = do repoCreateTicketF now shrRecip rpRecip author body mfwd luCreate ticket muTarget = do
ParsedCreateTicket targetAndContext tlocal published title desc src <- ParsedCreateTicket targetAndContext tlocal published title desc src <-
checkCreateTicket author ticket muTarget checkCreateTicket author ticket muTarget
mmhttp <- for (targetRelevance targetAndContext) $ \ (mb, vcs, _diff) -> runDBExcept $ do mmhttp <- for (targetRelevance targetAndContext) $ \ (mb, vcs, diff) -> runDBExcept $ do
Entity rid r <- lift $ do Entity rid r <- lift $ do
sid <- getKeyBy404 $ UniqueSharer shrRecip sid <- getKeyBy404 $ UniqueSharer shrRecip
getBy404 $ UniqueRepo rpRecip sid getBy404 $ UniqueRepo rpRecip sid
@ -993,7 +993,8 @@ repoCreateTicketF now shrRecip rpRecip author body mfwd luCreate ticket muTarget
let mkTRL tclid = TicketRepoLocal tclid rid mb let mkTRL tclid = TicketRepoLocal tclid rid mb
result <- insertRemoteTicket mkTRL author (AP.ticketId tlocal) published title desc src ractid obiidAccept result <- insertRemoteTicket mkTRL author (AP.ticketId tlocal) published title desc src ractid obiidAccept
unless (isRight result) $ delete obiidAccept unless (isRight result) $ delete obiidAccept
for result $ \ () -> do for result $ \ tid -> do
insert_ $ Patch tid published diff
mremotesHttpFwd <- for mfwd $ \ (localRecips, sig) -> do mremotesHttpFwd <- for mfwd $ \ (localRecips, sig) -> do
let sieve = let sieve =
makeRecipientSet makeRecipientSet