mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-22 08:46:54 -06:00
Unfollow with host
This commit is contained in:
parent
a7d647c440
commit
39fdb3c032
@ -47,7 +47,7 @@ export class FollowService {
|
||||
}
|
||||
|
||||
unfollow (follow: AccountFollow) {
|
||||
return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.id)
|
||||
return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host)
|
||||
.map(this.restExtractor.extractDataBool)
|
||||
.catch(res => this.restExtractor.handleError(res))
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { Response } from 'express'
|
||||
import * as validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers'
|
||||
import { ActorModel } from '../../../models/activitypub/actor'
|
||||
import { isAccountNameValid } from '../accounts'
|
||||
import { exists, isUUIDValid } from '../misc'
|
||||
import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels'
|
||||
@ -88,40 +85,6 @@ function isActorAcceptActivityValid (activity: any) {
|
||||
return isBaseActivityValid(activity, 'Accept')
|
||||
}
|
||||
|
||||
function isActorIdExist (id: number | string, res: Response) {
|
||||
let promise: Bluebird<ActorModel>
|
||||
|
||||
if (validator.isInt('' + id)) {
|
||||
promise = ActorModel.load(+id)
|
||||
} else { // UUID
|
||||
promise = ActorModel.loadByUUID('' + id)
|
||||
}
|
||||
|
||||
return isActorExist(promise, res)
|
||||
}
|
||||
|
||||
function isLocalActorNameExist (name: string, res: Response) {
|
||||
const promise = ActorModel.loadLocalByName(name)
|
||||
|
||||
return isActorExist(promise, res)
|
||||
}
|
||||
|
||||
async function isActorExist (p: Bluebird<ActorModel>, res: Response) {
|
||||
const actor = await p
|
||||
|
||||
if (!actor) {
|
||||
res.status(404)
|
||||
.send({ error: 'Actor not found' })
|
||||
.end()
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.actor = actor
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
@ -137,8 +100,5 @@ export {
|
||||
isActorFollowActivityValid,
|
||||
isActorAcceptActivityValid,
|
||||
isActorDeleteActivityValid,
|
||||
isActorIdExist,
|
||||
isLocalActorNameExist,
|
||||
isActorNameValid,
|
||||
isActorExist
|
||||
isActorNameValid
|
||||
}
|
||||
|
@ -167,12 +167,12 @@ async function up (utils: {
|
||||
|
||||
const query1 = `UPDATE "actorFollow"
|
||||
SET "actorId" =
|
||||
(SELECT "actorId" FROM account WHERE id = "actorFollow"."actorId")`
|
||||
(SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."actorId")`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
const query2 = `UPDATE "actorFollow"
|
||||
SET "targetActorId" =
|
||||
(SELECT "actorId" FROM account WHERE id = "actorFollow"."actorId")`
|
||||
(SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."targetActorId")`
|
||||
|
||||
await utils.sequelize.query(query2)
|
||||
}
|
||||
|
@ -62,5 +62,5 @@ async function follow (actor: ActorModel, targetActorURL: string) {
|
||||
return sendAccept(actorFollow, t)
|
||||
})
|
||||
|
||||
logger.info('Actor uuid %s is followed by actor %s.', actor.url, targetActorURL)
|
||||
logger.info('Actor %s is followed by actor %s.', actor.url, targetActorURL)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user