'use strict' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI } from '@Route-Tools/middleware' ; import { accountFromAuthToken , accountFromParams } from '@Route-Tools/middleware' ; import { buildLocationInfo } from '@Route-Tools/Util' ; import { Perm } from '@Route-Tools/Perm' ; import { checkAccessToEntity } from '@Route-Tools/Permissions' ; const procGetUserLocation = async ( req , resp , next ) => { if ( req . vAuthAccount ) { if ( req . vAccount ) { if ( await checkAccessToEntity ( req . vAuthToken , req . vAccount , [ Perm . OWNER , Perm . FRIEND , Perm . CONNECTION , Perm . ADMIN ] , req . vAuthAccount ) ) { req . vRestResp . Data = { 'location' : await buildLocationInfo ( req . vAccount ) } ; } else { req . vRestResp . respondFailure ( 'unauthorized' ) ; } } else { req . vRestResp . respondFailure ( 'target account not found' ) ; } ; } else { req . vRestResp . respondFailure ( req . vAccountError ?? 'Not logged in' ) ; } ; next ( ) ; } ; export const name = '/api/v1/users/:accountId/location' ; export const router = Router ( ) ; router . get ( '/api/v1/users/:accountId/location' , [ setupMetaverseAPI , accountFromAuthToken , accountFromParams , procGetUserLocation , finishMetaverseAPI ] ) ;