DB: Give each actor a secondary inbox, for collecting errors
This commit is contained in:
parent
ef036fd08b
commit
29e7581b19
7 changed files with 46 additions and 39 deletions
18
migrations/625_2024-04-27_errbox.model
Normal file
18
migrations/625_2024-04-27_errbox.model
Normal file
|
@ -0,0 +1,18 @@
|
|||
Outbox
|
||||
FollowerSet
|
||||
|
||||
Inbox
|
||||
|
||||
Actor
|
||||
name Text
|
||||
desc Text
|
||||
createdAt UTCTime
|
||||
inbox InboxId
|
||||
outbox OutboxId
|
||||
followers FollowerSetId
|
||||
justCreatedBy ActorId Maybe
|
||||
errbox InboxId
|
||||
|
||||
UniqueActorInbox inbox
|
||||
UniqueActorOutbox outbox
|
||||
UniqueActorFollowers followers
|
|
@ -460,18 +460,7 @@ clientCreateDeck now personMeID (ClientMsg maybeCap localRecips remoteRecips fwd
|
|||
entityKey <$> fromMaybeE mw "Can't find a workflow"
|
||||
|
||||
insertDeck now name msummary obiidCreate wid actorMeID = do
|
||||
ibid <- insert Inbox
|
||||
obid <- insert Outbox
|
||||
fsid <- insert FollowerSet
|
||||
aid <- insert Actor
|
||||
{ actorName = name
|
||||
, actorDesc = fromMaybe "" msummary
|
||||
, actorCreatedAt = now
|
||||
, actorInbox = ibid
|
||||
, actorOutbox = obid
|
||||
, actorFollowers = fsid
|
||||
, actorJustCreatedBy = Just actorMeID
|
||||
}
|
||||
Entity aid a <- insertActor now name (fromMaybe "" msummary) (Just actorMeID)
|
||||
rid <- insert $ Resource aid
|
||||
did <- insert Deck
|
||||
{ deckActor = aid
|
||||
|
@ -481,7 +470,7 @@ clientCreateDeck now personMeID (ClientMsg maybeCap localRecips remoteRecips fwd
|
|||
, deckWiki = Nothing
|
||||
, deckCreate = obiidCreate
|
||||
}
|
||||
return (did, rid, fsid)
|
||||
return (did, rid, actorFollowers a)
|
||||
|
||||
prepareCreate name msummary deckHash = do
|
||||
encodeRouteLocal <- getEncodeRouteLocal
|
||||
|
@ -629,25 +618,14 @@ clientCreateProject now personMeID (ClientMsg maybeCap localRecips remoteRecips
|
|||
return (name, msummary)
|
||||
|
||||
insertProject now name msummary obiidCreate actorMeID = do
|
||||
ibid <- insert Inbox
|
||||
obid <- insert Outbox
|
||||
fsid <- insert FollowerSet
|
||||
aid <- insert Actor
|
||||
{ actorName = name
|
||||
, actorDesc = fromMaybe "" msummary
|
||||
, actorCreatedAt = now
|
||||
, actorInbox = ibid
|
||||
, actorOutbox = obid
|
||||
, actorFollowers = fsid
|
||||
, actorJustCreatedBy = Just actorMeID
|
||||
}
|
||||
Entity aid a <- insertActor now name (fromMaybe "" msummary) (Just actorMeID)
|
||||
rid <- insert $ Resource aid
|
||||
did <- insert Project
|
||||
{ projectActor = aid
|
||||
, projectResource = rid
|
||||
, projectCreate = obiidCreate
|
||||
}
|
||||
return (did, rid, fsid)
|
||||
return (did, rid, actorFollowers a)
|
||||
|
||||
prepareCreate name msummary projectHash = do
|
||||
encodeRouteLocal <- getEncodeRouteLocal
|
||||
|
@ -795,25 +773,14 @@ clientCreateTeam now personMeID (ClientMsg maybeCap localRecips remoteRecips fwd
|
|||
return (name, msummary)
|
||||
|
||||
insertTeam now name msummary obiidCreate actorMeID = do
|
||||
ibid <- insert Inbox
|
||||
obid <- insert Outbox
|
||||
fsid <- insert FollowerSet
|
||||
aid <- insert Actor
|
||||
{ actorName = name
|
||||
, actorDesc = fromMaybe "" msummary
|
||||
, actorCreatedAt = now
|
||||
, actorInbox = ibid
|
||||
, actorOutbox = obid
|
||||
, actorFollowers = fsid
|
||||
, actorJustCreatedBy = Just actorMeID
|
||||
}
|
||||
Entity aid a <- insertActor now name (fromMaybe "" msummary) (Just actorMeID)
|
||||
rid <- insert $ Resource aid
|
||||
gid <- insert Group
|
||||
{ groupActor = aid
|
||||
, groupResource = rid
|
||||
, groupCreate = obiidCreate
|
||||
}
|
||||
return (gid, rid, fsid)
|
||||
return (gid, rid, actorFollowers a)
|
||||
|
||||
prepareCreate name msummary groupHash = do
|
||||
encodeRouteLocal <- getEncodeRouteLocal
|
||||
|
|
|
@ -663,6 +663,7 @@ instance AccountDB AccountPersistDB' where
|
|||
addNewUser name email key pwd = AccountPersistDB' $ runDB $ do
|
||||
now <- liftIO getCurrentTime
|
||||
ibid <- insert Inbox
|
||||
rbid <- insert Inbox
|
||||
obid <- insert Outbox
|
||||
fsid <- insert FollowerSet
|
||||
let actor = Actor
|
||||
|
@ -673,6 +674,7 @@ instance AccountDB AccountPersistDB' where
|
|||
, actorOutbox = obid
|
||||
, actorFollowers = fsid
|
||||
, actorJustCreatedBy = Nothing
|
||||
, actorErrbox = rbid
|
||||
}
|
||||
aid <- insert actor
|
||||
let defTime = UTCTime (ModifiedJulianDay 0) 0
|
||||
|
|
|
@ -3604,6 +3604,20 @@ changes hLocal ctx =
|
|||
, removeEntity "CollabTopicGroup"
|
||||
-- 624
|
||||
, addFieldPrimRequired "InboxItem" T.empty "result"
|
||||
-- 625
|
||||
, addFieldRefRequired''
|
||||
"Actor"
|
||||
(insertEntity Inbox625)
|
||||
(Just $ \ (Entity tempInboxID Inbox625) -> do
|
||||
l <- selectKeysList [] []
|
||||
for_ l $ \ k -> do
|
||||
inboxID <- insert Inbox625
|
||||
update k [Actor625Errbox =. inboxID]
|
||||
|
||||
delete tempInboxID
|
||||
)
|
||||
"errbox"
|
||||
"Inbox"
|
||||
]
|
||||
|
||||
migrateDB
|
||||
|
|
|
@ -66,3 +66,6 @@ makeEntitiesMigration "604"
|
|||
|
||||
makeEntitiesMigration "611"
|
||||
$(modelFile "migrations/611_2024-04-20_permit_resource.model")
|
||||
|
||||
makeEntitiesMigration "625"
|
||||
$(modelFile "migrations/625_2024-04-27_errbox.model")
|
||||
|
|
|
@ -211,6 +211,7 @@ getRemoteActivityURI act = do
|
|||
|
||||
insertActor now name desc mby = do
|
||||
ibid <- insert Inbox
|
||||
rbid <- insert Inbox
|
||||
obid <- insert Outbox
|
||||
fsid <- insert FollowerSet
|
||||
let actor = Actor
|
||||
|
@ -221,6 +222,7 @@ insertActor now name desc mby = do
|
|||
, actorOutbox = obid
|
||||
, actorFollowers = fsid
|
||||
, actorJustCreatedBy = mby
|
||||
, actorErrbox = rbid
|
||||
}
|
||||
actorID <- insert actor
|
||||
return $ Entity actorID actor
|
||||
|
|
|
@ -121,6 +121,7 @@ Actor
|
|||
outbox OutboxId
|
||||
followers FollowerSetId
|
||||
justCreatedBy ActorId Maybe
|
||||
errbox InboxId
|
||||
|
||||
UniqueActorInbox inbox
|
||||
UniqueActorOutbox outbox
|
||||
|
|
Loading…
Reference in a new issue