mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 18:53:08 +02:00
Fix bug
This commit is contained in:
parent
5ff59b3339
commit
509cdae832
2 changed files with 23 additions and 11 deletions
|
@ -47,16 +47,28 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
|
|||
|
||||
const object = await resolver.resolve(value) as any;
|
||||
|
||||
if (
|
||||
object == null ||
|
||||
object.type !== 'Person' ||
|
||||
typeof object.preferredUsername !== 'string' ||
|
||||
typeof object.inbox !== 'string' ||
|
||||
!validateUsername(object.preferredUsername) ||
|
||||
!isValidName(object.name == '' ? null : object.name)
|
||||
) {
|
||||
log(`invalid person: ${JSON.stringify(object, null, 2)}`);
|
||||
throw new Error('invalid person');
|
||||
if (object == null) {
|
||||
throw new Error('invalid person: object is null');
|
||||
}
|
||||
|
||||
if (object.type != 'Person' && object.type != 'Service') {
|
||||
throw new Error('invalid person: object is not a person or service');
|
||||
}
|
||||
|
||||
if (typeof object.preferredUsername !== 'string') {
|
||||
throw new Error('invalid person: preferredUsername is not a string');
|
||||
}
|
||||
|
||||
if (typeof object.inbox !== 'string') {
|
||||
throw new Error('invalid person: inbox is not a string');
|
||||
}
|
||||
|
||||
if (!validateUsername(object.preferredUsername)) {
|
||||
throw new Error('invalid person: invalid username');
|
||||
}
|
||||
|
||||
if (!isValidName(object.name == '' ? null : object.name)) {
|
||||
throw new Error('invalid person: invalid name');
|
||||
}
|
||||
|
||||
const person: IPerson = object;
|
||||
|
|
|
@ -7,7 +7,7 @@ export default (user: ILocalUser) => {
|
|||
const id = `${config.url}/users/${user._id}`;
|
||||
|
||||
return {
|
||||
type: 'Person',
|
||||
type: user.isBot ? 'Service' : 'Person',
|
||||
id,
|
||||
inbox: `${id}/inbox`,
|
||||
outbox: `${id}/outbox`,
|
||||
|
|
Loading…
Reference in a new issue