Write submission records

This commit is contained in:
Eric Bailey
2024-10-23 12:10:01 -05:00
parent 1e0221f9c1
commit de9903b379
4 changed files with 75 additions and 3 deletions
+21
View File
@@ -18,6 +18,7 @@ import {isNetworkError} from '#/lib/strings/errors'
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
import {logger} from '#/logger'
import {compressImage} from '#/state/gallery'
import {writeFeedSubmissionRecords} from '#/state/queries/feedgens'
import {writePostgateRecord} from '#/state/queries/postgate'
import {
fetchResolveGifQuery,
@@ -173,6 +174,26 @@ export async function post(
}
}
if (draft.feeds?.length) {
try {
await writeFeedSubmissionRecords({
agent,
records: draft.feeds.map(feedUri => ({
feedUri,
postUri: res.uri,
})),
})
} catch (e: any) {
logger.error(`Failed to create submission records`, {
context: 'composer',
safeMessage: e.message,
})
throw new Error(
t`Failed to write feed submission records. Your post was created, but it was not submitted to any feeds.`,
)
}
}
return res
}