Add field errorSince to RemoteActor to track inbox POST unreachability

This commit is contained in:
fr33domlover 2019-04-12 01:09:45 +00:00
parent 3f9364e4aa
commit 7946fe441d
5 changed files with 15 additions and 9 deletions

View file

@ -70,9 +70,10 @@ VerifKeySharedUsage
UniqueVerifKeySharedUsage key user UniqueVerifKeySharedUsage key user
RemoteActor RemoteActor
ident LocalURI ident LocalURI
instance InstanceId instance InstanceId
inbox LocalURI inbox LocalURI
errorSince UTCTime Maybe
UniqueRemoteActor instance ident UniqueRemoteActor instance ident

View file

@ -384,7 +384,7 @@ handleOutboxNote host (Note mluNote luAttrib aud muParent muContext mpublished c
Right actor -> withHostLock hRecip $ runDB $ do Right actor -> withHostLock hRecip $ runDB $ do
iid <- either entityKey id <$> insertBy (Instance hRecip) iid <- either entityKey id <$> insertBy (Instance hRecip)
let luInbox = actorInbox actor let luInbox = actorInbox actor
rsid <- either entityKey id <$> insertBy (RemoteActor luRecip iid luInbox) rsid <- either entityKey id <$> insertBy (RemoteActor luRecip iid luInbox Nothing)
update rdid [RemoteDiscussionActor =. Just rsid, RemoteDiscussionUnlinkedActor =. Nothing] update rdid [RemoteDiscussionActor =. Just rsid, RemoteDiscussionUnlinkedActor =. Nothing]
return $ l2f hRecip luInbox return $ l2f hRecip luInbox
-- TODO based on the httpPostAP usage in postOutboxR -- TODO based on the httpPostAP usage in postOutboxR

View file

@ -319,7 +319,7 @@ postOutboxR shr = do
case miid of case miid of
Just iid -> return (iid, False) Just iid -> return (iid, False)
Nothing -> idAndNew <$> insertBy (Instance h) Nothing -> idAndNew <$> insertBy (Instance h)
let rs = RemoteActor lto iid inbox let rs = RemoteActor lto iid inbox Nothing
if inew if inew
then insert_ rs then insert_ rs
else insertUnique_ rs else insertUnique_ rs

View file

@ -238,6 +238,11 @@ changes =
, renameEntity "RemoteSharer" "RemoteActor" , renameEntity "RemoteSharer" "RemoteActor"
-- 57 -- 57
, renameUnique "RemoteActor" "UniqueRemoteSharer" "UniqueRemoteActor" , renameUnique "RemoteActor" "UniqueRemoteSharer" "UniqueRemoteActor"
-- 58
, addFieldPrimOptional
"RemoteActor"
(Nothing :: Maybe UTCTime)
"errorSince"
] ]
migrateDB :: MonadIO m => ReaderT SqlBackend m (Either Text (Int, Int)) migrateDB :: MonadIO m => ReaderT SqlBackend m (Either Text (Int, Int))

View file

@ -135,7 +135,7 @@ instanceAndActor
-> YesodDB site (InstanceId, RemoteActorId, Maybe Bool) -> YesodDB site (InstanceId, RemoteActorId, Maybe Bool)
instanceAndActor host luActor luInbox = do instanceAndActor host luActor luInbox = do
(iid, inew) <- idAndNew <$> insertBy (Instance host) (iid, inew) <- idAndNew <$> insertBy (Instance host)
let rs = RemoteActor luActor iid luInbox let rs = RemoteActor luActor iid luInbox Nothing
if inew if inew
then do then do
rsid <- insert rs rsid <- insert rs
@ -329,7 +329,7 @@ keyListedByActorShared iid vkid host luKey luActor = do
RoomModeInstant -> do RoomModeInstant -> do
when reject $ throwE "Actor key storage limit is 0 and set to reject" when reject $ throwE "Actor key storage limit is 0 and set to reject"
luInbox <- actorInbox <$> ExceptT (keyListedByActor manager host luKey luActor) luInbox <- actorInbox <$> ExceptT (keyListedByActor manager host luKey luActor)
lift $ runDB $ either entityKey id <$> insertBy (RemoteActor luActor iid luInbox) lift $ runDB $ either entityKey id <$> insertBy (RemoteActor luActor iid luInbox Nothing)
RoomModeCached m -> do RoomModeCached m -> do
eresult <- do eresult <- do
ments <- lift $ runDB $ do ments <- lift $ runDB $ do
@ -352,7 +352,7 @@ keyListedByActorShared iid vkid host luKey luActor = do
vkExists <- isJust <$> get vkid vkExists <- isJust <$> get vkid
case mrsid of case mrsid of
Nothing -> do Nothing -> do
rsid <- insert $ RemoteActor luActor iid luInbox rsid <- insert $ RemoteActor luActor iid luInbox Nothing
when vkExists $ insert_ $ VerifKeySharedUsage vkid rsid when vkExists $ insert_ $ VerifKeySharedUsage vkid rsid
return $ Right rsid return $ Right rsid
Just rsid -> runExceptT $ do Just rsid -> runExceptT $ do
@ -464,7 +464,7 @@ actorFetchShareSettings = ResultShareSettings
manager <- getsYesod getHttpManager manager <- getsYesod getHttpManager
eactor <- fetchAPID manager actorId h lu eactor <- fetchAPID manager actorId h lu
for eactor $ \ actor -> runDB $ for eactor $ \ actor -> runDB $
insertEntity $ RemoteActor lu iid (actorInbox actor) insertEntity $ RemoteActor lu iid (actorInbox actor) Nothing
} }
fetchRemoteActor fetchRemoteActor