mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-26 07:26:27 -08:00
huhh
This commit is contained in:
parent
93b277e5b8
commit
06856ae422
|
@ -17,6 +17,14 @@ export const getAccount: RequestHandler = function (ctx, next) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveTarget(actor: Accounts.Account, targetString: string) {
|
||||||
|
return targetString == "me"
|
||||||
|
? actor
|
||||||
|
: targetString.startsWith("@")
|
||||||
|
? Accounts.getFromUsername(targetString.slice(1))
|
||||||
|
: Accounts.getFromId(targetString)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description use :user param to get a target for this route
|
* @description use :user param to get a target for this route
|
||||||
*/
|
*/
|
||||||
|
@ -29,12 +37,7 @@ export const getTarget: RequestHandler = async (ctx, next) => {
|
||||||
|
|
||||||
let actor = ctx.get("account")
|
let actor = ctx.get("account")
|
||||||
|
|
||||||
let target =
|
let target = resolveTarget(actor, ctx.req.param("user"))
|
||||||
ctx.req.param("user") == "me"
|
|
||||||
? actor
|
|
||||||
: ctx.req.param("user").startsWith("@")
|
|
||||||
? Accounts.getFromUsername(ctx.req.param("user").slice(1))
|
|
||||||
: Accounts.getFromId(ctx.req.param("user"))
|
|
||||||
|
|
||||||
if (!target) return ServeError(ctx, 404, "account does not exist")
|
if (!target) return ServeError(ctx, 404, "account does not exist")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue