+async function areSubscriptionsExist (req: express.Request, res: express.Response) {
+ const uris = req.query.uris as string[]
+ const user = res.locals.oauth.token.User as UserModel
+
+ const handles = uris.map(u => {
+ let [ name, host ] = u.split('@')
+ if (host === CONFIG.WEBSERVER.HOST) host = null
+
+ return { name, host, uri: u }
+ })
+
+ const results = await ActorFollowModel.listSubscribedIn(user.Account.Actor.id, handles)
+
+ const existObject: { [id: string ]: boolean } = {}
+ for (const handle of handles) {
+ const obj = results.find(r => {
+ const server = r.ActorFollowing.Server
+
+ return r.ActorFollowing.preferredUsername === handle.name &&
+ (
+ (!server && !handle.host) ||
+ (server.host === handle.host)
+ )
+ })
+
+ existObject[handle.uri] = obj !== undefined
+ }
+
+ return res.json(existObject)
+}
+