Unfollow with host
authorChocobozzz <me@florianbigard.com>
Fri, 15 Dec 2017 16:38:48 +0000 (17:38 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 19 Dec 2017 09:53:16 +0000 (10:53 +0100)
client/src/app/+admin/follows/shared/follow.service.ts
server/helpers/custom-validators/activitypub/actor.ts
server/initializers/migrations/0130-video-channel-actor.ts
server/lib/activitypub/process/process-follow.ts

index 3a430ff6429f06a85c82f456ba48944c27d3e669..089be9d64542cd1054880db1467b1e2c3ad8d579 100644 (file)
@@ -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))
   }
index bf42757c59005d95bce30a7934f2d1e8bdd30c06..5930bd5daeab0abe90abfe63f7b938ae6fcdc7dd 100644 (file)
@@ -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
 }
index 72a0daef7debae5de67daf52935be372e325531c..0b665b0c750fa4b5c1b20900734b8cce9309c575 100644 (file)
@@ -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)
   }
index ec7a331f30809e41a22529e9ad8fe3a950111a20..bc02d5043835466e648804e3e2bfcd91de137b52 100644 (file)
@@ -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)
 }