parent
e523e54881
commit
f27e4033a6
@ -85,6 +85,7 @@ export class NoteRepository extends Repository<Note> {
|
|||||||
detail?: boolean;
|
detail?: boolean;
|
||||||
skipHide?: boolean;
|
skipHide?: boolean;
|
||||||
_hint_?: {
|
_hint_?: {
|
||||||
|
emojis: Emoji[] | null;
|
||||||
myReactions: Map<Note['id'], NoteReaction | null>;
|
myReactions: Map<Note['id'], NoteReaction | null>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -141,11 +142,43 @@ export class NoteRepository extends Repository<Note> {
|
|||||||
* @param reactionNames Note等にリアクションされたカスタム絵文字名 (:は含めない)
|
* @param reactionNames Note等にリアクションされたカスタム絵文字名 (:は含めない)
|
||||||
*/
|
*/
|
||||||
async function populateEmojis(emojiNames: string[], noteUserHost: string | null, reactionNames: string[]) {
|
async function populateEmojis(emojiNames: string[], noteUserHost: string | null, reactionNames: string[]) {
|
||||||
|
const customReactions = reactionNames?.map(x => decodeReaction(x)).filter(x => x.name);
|
||||||
|
|
||||||
let all = [] as {
|
let all = [] as {
|
||||||
name: string,
|
name: string,
|
||||||
url: string
|
url: string
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
|
// 与えられたhintだけで十分(=新たにクエリする必要がない)かどうかを表すフラグ
|
||||||
|
let enough = true;
|
||||||
|
if (options?._hint_?.emojis) {
|
||||||
|
for (const name of emojiNames) {
|
||||||
|
const matched = options._hint_.emojis.find(x => x.name === name && x.host === noteUserHost);
|
||||||
|
if (matched) {
|
||||||
|
all.push({
|
||||||
|
name: matched.name,
|
||||||
|
url: matched.url,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
enough = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const customReaction of customReactions) {
|
||||||
|
const matched = options._hint_.emojis.find(x => x.name === customReaction.name && x.host === customReaction.host);
|
||||||
|
if (matched) {
|
||||||
|
all.push({
|
||||||
|
name: `${matched.name}@${matched.host || '.'}`, // @host付きでローカルは.
|
||||||
|
url: matched.url,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
enough = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enough = false;
|
||||||
|
}
|
||||||
|
if (enough) return all;
|
||||||
|
|
||||||
// カスタム絵文字
|
// カスタム絵文字
|
||||||
if (emojiNames?.length > 0) {
|
if (emojiNames?.length > 0) {
|
||||||
const tmp = await Emojis.find({
|
const tmp = await Emojis.find({
|
||||||
@ -164,8 +197,6 @@ export class NoteRepository extends Repository<Note> {
|
|||||||
all = concat([all, tmp]);
|
all = concat([all, tmp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const customReactions = reactionNames?.map(x => decodeReaction(x)).filter(x => x.name);
|
|
||||||
|
|
||||||
if (customReactions?.length > 0) {
|
if (customReactions?.length > 0) {
|
||||||
const where = [] as {}[];
|
const where = [] as {}[];
|
||||||
|
|
||||||
@ -230,7 +261,12 @@ export class NoteRepository extends Repository<Note> {
|
|||||||
id: note.id,
|
id: note.id,
|
||||||
createdAt: note.createdAt.toISOString(),
|
createdAt: note.createdAt.toISOString(),
|
||||||
userId: note.userId,
|
userId: note.userId,
|
||||||
user: Users.pack(note.user || note.userId, meId),
|
user: Users.pack(note.user || note.userId, meId, {
|
||||||
|
detail: false,
|
||||||
|
_hint_: {
|
||||||
|
emojis: options?._hint_?.emojis || null
|
||||||
|
}
|
||||||
|
}),
|
||||||
text: text,
|
text: text,
|
||||||
cw: note.cw,
|
cw: note.cw,
|
||||||
visibility: note.visibility,
|
visibility: note.visibility,
|
||||||
@ -258,12 +294,12 @@ export class NoteRepository extends Repository<Note> {
|
|||||||
_prId_: (note as any)._prId_ || undefined,
|
_prId_: (note as any)._prId_ || undefined,
|
||||||
|
|
||||||
...(opts.detail ? {
|
...(opts.detail ? {
|
||||||
reply: note.replyId ? this.pack(note.replyId, meId, {
|
reply: note.replyId ? this.pack(note.reply || note.replyId, meId, {
|
||||||
detail: false,
|
detail: false,
|
||||||
_hint_: options?._hint_
|
_hint_: options?._hint_
|
||||||
}) : undefined,
|
}) : undefined,
|
||||||
|
|
||||||
renote: note.renoteId ? this.pack(note.renoteId, meId, {
|
renote: note.renoteId ? this.pack(note.renote || note.renoteId, meId, {
|
||||||
detail: true,
|
detail: true,
|
||||||
_hint_: options?._hint_
|
_hint_: options?._hint_
|
||||||
}) : undefined,
|
}) : undefined,
|
||||||
@ -314,10 +350,48 @@ export class NoteRepository extends Repository<Note> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: ここら辺の処理をaggregateEmojisみたいな関数に切り出したい
|
||||||
|
let emojisWhere: any[] = [];
|
||||||
|
for (const note of notes) {
|
||||||
|
if (typeof note !== 'object') continue;
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.emojis),
|
||||||
|
host: note.userHost
|
||||||
|
});
|
||||||
|
if (note.renote) {
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.renote.emojis),
|
||||||
|
host: note.renote.userHost
|
||||||
|
});
|
||||||
|
if (note.renote.user) {
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.renote.user.emojis),
|
||||||
|
host: note.renote.userHost
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const customReactions = Object.keys(note.reactions).map(x => decodeReaction(x)).filter(x => x.name);
|
||||||
|
emojisWhere = emojisWhere.concat(customReactions.map(x => ({
|
||||||
|
name: x.name,
|
||||||
|
host: x.host
|
||||||
|
})));
|
||||||
|
if (note.user) {
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.user.emojis),
|
||||||
|
host: note.userHost
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const emojis = emojisWhere.length > 0 ? await Emojis.find({
|
||||||
|
where: emojisWhere,
|
||||||
|
select: ['name', 'host', 'url']
|
||||||
|
}) : null;
|
||||||
|
|
||||||
return await Promise.all(notes.map(n => this.pack(n, me, {
|
return await Promise.all(notes.map(n => this.pack(n, me, {
|
||||||
...options,
|
...options,
|
||||||
_hint_: {
|
_hint_: {
|
||||||
myReactions: myReactionsMap
|
myReactions: myReactionsMap,
|
||||||
|
emojis: emojis
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { EntityRepository, In, Repository } from 'typeorm';
|
import { EntityRepository, In, Repository } from 'typeorm';
|
||||||
import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions } from '..';
|
import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions, Emojis } from '..';
|
||||||
import { Notification } from '../entities/notification';
|
import { Notification } from '../entities/notification';
|
||||||
import { awaitAll } from '../../prelude/await-all';
|
import { awaitAll } from '../../prelude/await-all';
|
||||||
import { SchemaType } from '../../misc/schema';
|
import { SchemaType } from '../../misc/schema';
|
||||||
import { Note } from '../entities/note';
|
import { Note } from '../entities/note';
|
||||||
import { NoteReaction } from '../entities/note-reaction';
|
import { NoteReaction } from '../entities/note-reaction';
|
||||||
import { User } from '../entities/user';
|
import { User } from '../entities/user';
|
||||||
|
import { decodeReaction } from '../../misc/reaction-lib';
|
||||||
|
import { Emoji } from '../entities/emoji';
|
||||||
|
|
||||||
export type PackedNotification = SchemaType<typeof packedNotificationSchema>;
|
export type PackedNotification = SchemaType<typeof packedNotificationSchema>;
|
||||||
|
|
||||||
@ -15,6 +17,7 @@ export class NotificationRepository extends Repository<Notification> {
|
|||||||
src: Notification['id'] | Notification,
|
src: Notification['id'] | Notification,
|
||||||
options: {
|
options: {
|
||||||
_hintForEachNotes_: {
|
_hintForEachNotes_: {
|
||||||
|
emojis: Emoji[] | null;
|
||||||
myReactions: Map<Note['id'], NoteReaction | null>;
|
myReactions: Map<Note['id'], NoteReaction | null>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -98,9 +101,47 @@ export class NotificationRepository extends Repository<Notification> {
|
|||||||
myReactionsMap.set(target, myReactions.find(reaction => reaction.noteId === target) || null);
|
myReactionsMap.set(target, myReactions.find(reaction => reaction.noteId === target) || null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: ここら辺の処理をaggregateEmojisみたいな関数に切り出したい
|
||||||
|
let emojisWhere: any[] = [];
|
||||||
|
for (const note of notes) {
|
||||||
|
if (typeof note !== 'object') continue;
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.emojis),
|
||||||
|
host: note.userHost
|
||||||
|
});
|
||||||
|
if (note.renote) {
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.renote.emojis),
|
||||||
|
host: note.renote.userHost
|
||||||
|
});
|
||||||
|
if (note.renote.user) {
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.renote.user.emojis),
|
||||||
|
host: note.renote.userHost
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const customReactions = Object.keys(note.reactions).map(x => decodeReaction(x)).filter(x => x.name);
|
||||||
|
emojisWhere = emojisWhere.concat(customReactions.map(x => ({
|
||||||
|
name: x.name,
|
||||||
|
host: x.host
|
||||||
|
})));
|
||||||
|
if (note.user) {
|
||||||
|
emojisWhere.push({
|
||||||
|
name: In(note.user.emojis),
|
||||||
|
host: note.userHost
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const emojis = emojisWhere.length > 0 ? await Emojis.find({
|
||||||
|
where: emojisWhere,
|
||||||
|
select: ['name', 'host', 'url']
|
||||||
|
}) : null;
|
||||||
|
|
||||||
return await Promise.all(notifications.map(x => this.pack(x, {
|
return await Promise.all(notifications.map(x => this.pack(x, {
|
||||||
_hintForEachNotes_: {
|
_hintForEachNotes_: {
|
||||||
myReactions: myReactionsMap
|
myReactions: myReactionsMap,
|
||||||
|
emojis: emojis,
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { Emojis, Notes, NoteUnreads, FollowRequests, Notifications, MessagingMes
|
|||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
import { SchemaType } from '../../misc/schema';
|
import { SchemaType } from '../../misc/schema';
|
||||||
import { awaitAll } from '../../prelude/await-all';
|
import { awaitAll } from '../../prelude/await-all';
|
||||||
|
import { Emoji } from '../entities/emoji';
|
||||||
|
|
||||||
export type PackedUser = SchemaType<typeof packedUserSchema>;
|
export type PackedUser = SchemaType<typeof packedUserSchema>;
|
||||||
|
|
||||||
@ -149,6 +150,9 @@ export class UserRepository extends Repository<User> {
|
|||||||
options?: {
|
options?: {
|
||||||
detail?: boolean,
|
detail?: boolean,
|
||||||
includeSecrets?: boolean,
|
includeSecrets?: boolean,
|
||||||
|
_hint_?: {
|
||||||
|
emojis: Emoji[] | null;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
): Promise<PackedUser> {
|
): Promise<PackedUser> {
|
||||||
const opts = Object.assign({
|
const opts = Object.assign({
|
||||||
@ -166,6 +170,34 @@ export class UserRepository extends Repository<User> {
|
|||||||
}) : [];
|
}) : [];
|
||||||
const profile = opts.detail ? await UserProfiles.findOneOrFail(user.id) : null;
|
const profile = opts.detail ? await UserProfiles.findOneOrFail(user.id) : null;
|
||||||
|
|
||||||
|
let emojis: Emoji[] = [];
|
||||||
|
if (user.emojis.length > 0) {
|
||||||
|
// 与えられたhintだけで十分(=新たにクエリする必要がない)かどうかを表すフラグ
|
||||||
|
let enough = true;
|
||||||
|
if (options?._hint_?.emojis) {
|
||||||
|
for (const name of user.emojis) {
|
||||||
|
const matched = options._hint_.emojis.find(x => x.name === name && x.host === user.host);
|
||||||
|
if (matched) {
|
||||||
|
emojis.push(matched);
|
||||||
|
} else {
|
||||||
|
enough = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enough = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enough) {
|
||||||
|
emojis = await Emojis.find({
|
||||||
|
where: {
|
||||||
|
name: In(user.emojis),
|
||||||
|
host: user.host
|
||||||
|
},
|
||||||
|
select: ['name', 'host', 'url', 'aliases']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const falsy = opts.detail ? false : undefined;
|
const falsy = opts.detail ? false : undefined;
|
||||||
|
|
||||||
const packed = {
|
const packed = {
|
||||||
@ -190,13 +222,7 @@ export class UserRepository extends Repository<User> {
|
|||||||
} : undefined) : undefined,
|
} : undefined) : undefined,
|
||||||
|
|
||||||
// カスタム絵文字添付
|
// カスタム絵文字添付
|
||||||
emojis: user.emojis.length > 0 ? Emojis.find({
|
emojis: emojis,
|
||||||
where: {
|
|
||||||
name: In(user.emojis),
|
|
||||||
host: user.host
|
|
||||||
},
|
|
||||||
select: ['name', 'host', 'url', 'aliases']
|
|
||||||
}) : [],
|
|
||||||
|
|
||||||
...(opts.detail ? {
|
...(opts.detail ? {
|
||||||
url: profile!.url,
|
url: profile!.url,
|
||||||
|
@ -74,6 +74,10 @@ export default define(meta, async (ps, user) => {
|
|||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`note.id IN (${ antennaQuery.getQuery() })`)
|
.andWhere(`note.id IN (${ antennaQuery.getQuery() })`)
|
||||||
.leftJoinAndSelect('note.user', 'user')
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.setParameters(antennaQuery.getParameters());
|
.setParameters(antennaQuery.getParameters());
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
|
@ -88,6 +88,10 @@ export default define(meta, async (ps, user) => {
|
|||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||||
.andWhere('note.channelId = :channelId', { channelId: channel.id })
|
.andWhere('note.channelId = :channelId', { channelId: channel.id })
|
||||||
.leftJoinAndSelect('note.user', 'user')
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.leftJoinAndSelect('note.channel', 'channel');
|
.leftJoinAndSelect('note.channel', 'channel');
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
@ -72,6 +72,10 @@ export default define(meta, async (ps, user) => {
|
|||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`note.id IN (${ clipQuery.getQuery() })`)
|
.andWhere(`note.id IN (${ clipQuery.getQuery() })`)
|
||||||
.leftJoinAndSelect('note.user', 'user')
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.setParameters(clipQuery.getParameters());
|
.setParameters(clipQuery.getParameters());
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
|
@ -87,7 +87,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
.andWhere(`notification.notifieeId = :meId`, { meId: user.id })
|
.andWhere(`notification.notifieeId = :meId`, { meId: user.id })
|
||||||
.leftJoinAndSelect('notification.notifier', 'notifier')
|
.leftJoinAndSelect('notification.notifier', 'notifier')
|
||||||
.leftJoinAndSelect('notification.note', 'note')
|
.leftJoinAndSelect('notification.note', 'note')
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
query.andWhere(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`);
|
query.andWhere(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`);
|
||||||
query.setParameters(mutingQuery.getParameters());
|
query.setParameters(mutingQuery.getParameters());
|
||||||
|
@ -76,7 +76,11 @@ export default define(meta, async (ps) => {
|
|||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`note.visibility = 'public'`)
|
.andWhere(`note.visibility = 'public'`)
|
||||||
.andWhere(`note.localOnly = FALSE`)
|
.andWhere(`note.localOnly = FALSE`)
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
if (ps.local) {
|
if (ps.local) {
|
||||||
query.andWhere('note.userHost IS NULL');
|
query.andWhere('note.userHost IS NULL');
|
||||||
|
@ -64,7 +64,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
}))
|
}))
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
if (user) generateMutedUserQuery(query, user);
|
if (user) generateMutedUserQuery(query, user);
|
||||||
|
@ -49,7 +49,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
.andWhere(`note.score > 0`)
|
.andWhere(`note.score > 0`)
|
||||||
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) })
|
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) })
|
||||||
.andWhere(`note.visibility = 'public'`)
|
.andWhere(`note.visibility = 'public'`)
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
if (user) generateMutedUserQuery(query, user);
|
if (user) generateMutedUserQuery(query, user);
|
||||||
|
|
||||||
|
@ -81,7 +81,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||||
.andWhere('note.visibility = \'public\'')
|
.andWhere('note.visibility = \'public\'')
|
||||||
.andWhere('note.channelId IS NULL')
|
.andWhere('note.channelId IS NULL')
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateRepliesQuery(query, user);
|
generateRepliesQuery(query, user);
|
||||||
if (user) generateMutedUserQuery(query, user);
|
if (user) generateMutedUserQuery(query, user);
|
||||||
|
@ -130,6 +130,10 @@ export default define(meta, async (ps, user) => {
|
|||||||
.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');
|
.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');
|
||||||
}))
|
}))
|
||||||
.leftJoinAndSelect('note.user', 'user')
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.setParameters(followingQuery.getParameters());
|
.setParameters(followingQuery.getParameters());
|
||||||
|
|
||||||
generateChannelQuery(query, user);
|
generateChannelQuery(query, user);
|
||||||
|
@ -98,7 +98,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'),
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'),
|
||||||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||||
.andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)')
|
.andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)')
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateChannelQuery(query, user);
|
generateChannelQuery(query, user);
|
||||||
generateRepliesQuery(query, user);
|
generateRepliesQuery(query, user);
|
||||||
|
@ -63,7 +63,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
.where(`:meId = ANY(note.mentions)`, { meId: user.id })
|
.where(`:meId = ANY(note.mentions)`, { meId: user.id })
|
||||||
.orWhere(`:meId = ANY(note.visibleUserIds)`, { meId: user.id });
|
.orWhere(`:meId = ANY(note.visibleUserIds)`, { meId: user.id });
|
||||||
}))
|
}))
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
generateMutedUserQuery(query, user);
|
generateMutedUserQuery(query, user);
|
||||||
|
@ -68,7 +68,11 @@ export default define(meta, async (ps, user) => {
|
|||||||
|
|
||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`note.renoteId = :renoteId`, { renoteId: note.id })
|
.andWhere(`note.renoteId = :renoteId`, { renoteId: note.id })
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
if (user) generateMutedUserQuery(query, user);
|
if (user) generateMutedUserQuery(query, user);
|
||||||
|
@ -59,7 +59,11 @@ export const meta = {
|
|||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('note.replyId = :replyId', { replyId: ps.noteId })
|
.andWhere('note.replyId = :replyId', { replyId: ps.noteId })
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
if (user) generateMutedUserQuery(query, user);
|
if (user) generateMutedUserQuery(query, user);
|
||||||
|
@ -95,7 +95,11 @@ export const meta = {
|
|||||||
|
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, async (ps, me) => {
|
||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, me);
|
generateVisibilityQuery(query, me);
|
||||||
if (me) generateMutedUserQuery(query, me);
|
if (me) generateMutedUserQuery(query, me);
|
||||||
|
@ -79,7 +79,11 @@ export default define(meta, async (ps, me) => {
|
|||||||
|
|
||||||
query
|
query
|
||||||
.andWhere('note.text ILIKE :q', { q: `%${ps.query}%` })
|
.andWhere('note.text ILIKE :q', { q: `%${ps.query}%` })
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, me);
|
generateVisibilityQuery(query, me);
|
||||||
if (me) generateMutedUserQuery(query, me);
|
if (me) generateMutedUserQuery(query, me);
|
||||||
|
@ -123,6 +123,10 @@ export default define(meta, async (ps, user) => {
|
|||||||
if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`);
|
if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`);
|
||||||
}))
|
}))
|
||||||
.leftJoinAndSelect('note.user', 'user')
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.setParameters(followingQuery.getParameters());
|
.setParameters(followingQuery.getParameters());
|
||||||
|
|
||||||
generateChannelQuery(query, user);
|
generateChannelQuery(query, user);
|
||||||
|
@ -131,6 +131,10 @@ export default define(meta, async (ps, user) => {
|
|||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`note.userId IN (${ listQuery.getQuery() })`)
|
.andWhere(`note.userId IN (${ listQuery.getQuery() })`)
|
||||||
.leftJoinAndSelect('note.user', 'user')
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.setParameters(listQuery.getParameters());
|
.setParameters(listQuery.getParameters());
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
|
@ -131,7 +131,11 @@ export default define(meta, async (ps, me) => {
|
|||||||
//#region Construct query
|
//#region Construct query
|
||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||||
.andWhere('note.userId = :userId', { userId: user.id })
|
.andWhere('note.userId = :userId', { userId: user.id })
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user')
|
||||||
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
generateVisibilityQuery(query, me);
|
generateVisibilityQuery(query, me);
|
||||||
if (me) generateMutedUserQuery(query, me, user);
|
if (me) generateMutedUserQuery(query, me, user);
|
||||||
|
Loading…
Reference in New Issue
Block a user