test: mention fix

This commit is contained in:
Mar0xy 2023-09-26 01:16:03 +02:00
parent 3b2bf0dc35
commit 7df25f036a
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828

View file

@ -628,15 +628,6 @@ export default class Misskey implements MegalodonInterface {
}
}
return this.client.post<Array<MisskeyAPI.Entity.UserDetail>>('/api/users/search', params).then(res => {
if ((res.data as any)["error"]) {
return Object.assign(res, {
data: {
accounts: [],
statuses: [],
hashtags: [],
}
})
}
return Object.assign(res, {
data: res.data.map(u => MisskeyAPI.Converter.userDetail(u, this.baseUrl))
})
@ -2135,6 +2126,10 @@ export default class Misskey implements MegalodonInterface {
params = Object.assign(params, {
limit: options.limit
})
} else {
params = Object.assign(params, {
limit: 20,
});
}
if (options.offset) {
params = Object.assign(params, {
@ -2146,7 +2141,12 @@ export default class Misskey implements MegalodonInterface {
localOnly: options.resolve
})
}
} else {
params = Object.assign(params, {
limit: 20,
});
}
try {
const match = q.match(/^@?(?<user>[a-zA-Z0-9_]+)(?:@(?<host>[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)$/);
if (match) {
const lookupQuery = {
@ -2154,7 +2154,7 @@ export default class Misskey implements MegalodonInterface {
host: match.groups?.host,
};
return await this.client.post<MisskeyAPI.Entity.UserDetail>('/api/users/show', lookupQuery).then((res) => ({
const result = await this.client.post<MisskeyAPI.Entity.UserDetail>('/api/users/show', lookupQuery).then((res) => ({
...res,
data: {
accounts: [
@ -2167,7 +2167,20 @@ export default class Misskey implements MegalodonInterface {
hashtags: [],
},
}));
if (result.status !== 200) {
result.status = 200;
result.statusText = "OK";
result.data = {
accounts: [],
statuses: [],
hashtags: [],
};
}
return result;
}
} catch {}
return this.client.post<Array<MisskeyAPI.Entity.UserDetail>>('/api/users/search', params).then(res => ({
...res,
data: {