const actorUrl = getActorUrl(activity.actor)
if (activityToUndo.type === 'Like') {
- return processUndoLike(actorUrl, activity)
+ return retryTransactionWrapper(processUndoLike, actorUrl, activity)
} else if (activityToUndo.type === 'Create' && activityToUndo.object.type === 'Dislike') {
- return processUndoDislike(actorUrl, activity)
+ return retryTransactionWrapper(processUndoDislike, actorUrl, activity)
} else if (activityToUndo.type === 'Follow') {
- return processUndoFollow(actorUrl, activityToUndo)
+ return retryTransactionWrapper(processUndoFollow, actorUrl, activityToUndo)
} else if (activityToUndo.type === 'Announce') {
- return processUndoAnnounce(actorUrl, activityToUndo)
+ return retryTransactionWrapper(processUndoAnnounce, actorUrl, activityToUndo)
}
logger.warn('Unknown activity object type %s -> %s when undo activity.', activityToUndo.type, { activity: activity.id })
// ---------------------------------------------------------------------------
-function processUndoLike (actorUrl: string, activity: ActivityUndo) {
- const options = {
- arguments: [ actorUrl, activity ],
- errorMessage: 'Cannot undo like with many retries.'
- }
-
- return retryTransactionWrapper(undoLike, options)
-}
-
-async function undoLike (actorUrl: string, activity: ActivityUndo) {
+async function processUndoLike (actorUrl: string, activity: ActivityUndo) {
const likeActivity = activity.object as ActivityLike
const { video } = await getOrCreateAccountAndVideoAndChannel(likeActivity.object)
})
}
-function processUndoDislike (actorUrl: string, activity: ActivityUndo) {
- const options = {
- arguments: [ actorUrl, activity ],
- errorMessage: 'Cannot undo dislike with many retries.'
- }
-
- return retryTransactionWrapper(undoDislike, options)
-}
-
-async function undoDislike (actorUrl: string, activity: ActivityUndo) {
+async function processUndoDislike (actorUrl: string, activity: ActivityUndo) {
const dislike = activity.object.object as DislikeObject
const { video } = await getOrCreateAccountAndVideoAndChannel(dislike.object)
}
function processUndoFollow (actorUrl: string, followActivity: ActivityFollow) {
- const options = {
- arguments: [ actorUrl, followActivity ],
- errorMessage: 'Cannot undo follow with many retries.'
- }
-
- return retryTransactionWrapper(undoFollow, options)
-}
-
-function undoFollow (actorUrl: string, followActivity: ActivityFollow) {
return sequelizeTypescript.transaction(async t => {
const follower = await ActorModel.loadByUrl(actorUrl, t)
const following = await ActorModel.loadByUrl(followActivity.object, t)
}
function processUndoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) {
- const options = {
- arguments: [ actorUrl, announceActivity ],
- errorMessage: 'Cannot undo announce with many retries.'
- }
-
- return retryTransactionWrapper(undoAnnounce, options)
-}
-
-function undoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) {
return sequelizeTypescript.transaction(async t => {
const byAccount = await AccountModel.loadByUrl(actorUrl, t)
if (!byAccount) throw new Error('Unknown account ' + actorUrl)