diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-15 17:38:48 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 39fdb3c032875ab8c9a1e5e52f76d3baa0ac4e63 (patch) | |
tree | 01f1d3e8b51d20fc257e7c82dd75e03e3e02d349 /server/helpers | |
parent | a7d647c4403f8774106f485e8d9323158454e111 (diff) | |
download | PeerTube-39fdb3c032875ab8c9a1e5e52f76d3baa0ac4e63.tar.gz PeerTube-39fdb3c032875ab8c9a1e5e52f76d3baa0ac4e63.tar.zst PeerTube-39fdb3c032875ab8c9a1e5e52f76d3baa0ac4e63.zip |
Unfollow with host
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/activitypub/actor.ts | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index bf42757c5..5930bd5da 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts | |||
@@ -1,8 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { Response } from 'express' | ||
3 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
4 | import { CONSTRAINTS_FIELDS } from '../../../initializers' | 2 | import { CONSTRAINTS_FIELDS } from '../../../initializers' |
5 | import { ActorModel } from '../../../models/activitypub/actor' | ||
6 | import { isAccountNameValid } from '../accounts' | 3 | import { isAccountNameValid } from '../accounts' |
7 | import { exists, isUUIDValid } from '../misc' | 4 | import { exists, isUUIDValid } from '../misc' |
8 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' | 5 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels' |
@@ -88,40 +85,6 @@ function isActorAcceptActivityValid (activity: any) { | |||
88 | return isBaseActivityValid(activity, 'Accept') | 85 | return isBaseActivityValid(activity, 'Accept') |
89 | } | 86 | } |
90 | 87 | ||
91 | function isActorIdExist (id: number | string, res: Response) { | ||
92 | let promise: Bluebird<ActorModel> | ||
93 | |||
94 | if (validator.isInt('' + id)) { | ||
95 | promise = ActorModel.load(+id) | ||
96 | } else { // UUID | ||
97 | promise = ActorModel.loadByUUID('' + id) | ||
98 | } | ||
99 | |||
100 | return isActorExist(promise, res) | ||
101 | } | ||
102 | |||
103 | function isLocalActorNameExist (name: string, res: Response) { | ||
104 | const promise = ActorModel.loadLocalByName(name) | ||
105 | |||
106 | return isActorExist(promise, res) | ||
107 | } | ||
108 | |||
109 | async function isActorExist (p: Bluebird<ActorModel>, res: Response) { | ||
110 | const actor = await p | ||
111 | |||
112 | if (!actor) { | ||
113 | res.status(404) | ||
114 | .send({ error: 'Actor not found' }) | ||
115 | .end() | ||
116 | |||
117 | return false | ||
118 | } | ||
119 | |||
120 | res.locals.actor = actor | ||
121 | |||
122 | return true | ||
123 | } | ||
124 | |||
125 | // --------------------------------------------------------------------------- | 88 | // --------------------------------------------------------------------------- |
126 | 89 | ||
127 | export { | 90 | export { |
@@ -137,8 +100,5 @@ export { | |||
137 | isActorFollowActivityValid, | 100 | isActorFollowActivityValid, |
138 | isActorAcceptActivityValid, | 101 | isActorAcceptActivityValid, |
139 | isActorDeleteActivityValid, | 102 | isActorDeleteActivityValid, |
140 | isActorIdExist, | 103 | isActorNameValid |
141 | isLocalActorNameExist, | ||
142 | isActorNameValid, | ||
143 | isActorExist | ||
144 | } | 104 | } |