This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -17,7 +17,7 @@ export const meta = {
params: {
query: {
validator: $.str
validator: $.str,
},
sinceId: {
@ -30,22 +30,22 @@ export const meta = {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
host: {
validator: $.optional.nullable.str,
default: undefined
default: undefined,
},
userId: {
validator: $.optional.nullable.type(ID),
default: null
default: null,
},
channelId: {
validator: $.optional.nullable.type(ID),
default: null
default: null,
},
},
@ -56,11 +56,11 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Note',
}
},
},
errors: {
}
},
};
export default define(meta, async (ps, me) => {
@ -91,8 +91,8 @@ export default define(meta, async (ps, me) => {
} else {
const userQuery = ps.userId != null ? [{
term: {
userId: ps.userId
}
userId: ps.userId,
},
}] : [];
const hostQuery = ps.userId == null ?
@ -100,14 +100,14 @@ export default define(meta, async (ps, me) => {
bool: {
must_not: {
exists: {
field: 'userHost'
}
}
}
field: 'userHost',
},
},
},
}] : ps.host !== undefined ? [{
term: {
userHost: ps.host
}
userHost: ps.host,
},
}] : []
: [];
@ -122,15 +122,15 @@ export default define(meta, async (ps, me) => {
simple_query_string: {
fields: ['text'],
query: ps.query.toLowerCase(),
default_operator: 'and'
default_operator: 'and',
},
}, ...hostQuery, ...userQuery]
}
}, ...hostQuery, ...userQuery],
},
},
sort: [{
_doc: 'desc'
}]
}
_doc: 'desc',
}],
},
});
const hits = result.body.hits.hits.map((hit: any) => hit._id);
@ -140,11 +140,11 @@ export default define(meta, async (ps, me) => {
// Fetch found notes
const notes = await Notes.find({
where: {
id: In(hits)
id: In(hits),
},
order: {
id: -1
}
id: -1,
},
});
return await Notes.packMany(notes, me);