mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-29 09:23:04 +00:00
未実装のTLのRenoteクエリを実装 (#5343)
* users/notes includeMyRenotes * other renotes * fix target user in users/notes * users/notesからv10から未実装でありえないオプションを削除 * users/notesのincludeMyRenotesの説明を修正 * remove needless anonymous checks
This commit is contained in:
parent
ba93bf7478
commit
ab6a84cd45
4 changed files with 74 additions and 167 deletions
|
@ -130,59 +130,35 @@ export default define(meta, async (ps, user) => {
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
generateMuteQuery(query, user);
|
generateMuteQuery(query, user);
|
||||||
|
|
||||||
/* TODO
|
|
||||||
// MongoDBではトップレベルで否定ができないため、De Morganの法則を利用してクエリします。
|
|
||||||
// つまり、「『自分の投稿かつRenote』ではない」を「『自分の投稿ではない』または『Renoteではない』」と表現します。
|
|
||||||
// for details: https://en.wikipedia.org/wiki/De_Morgan%27s_laws
|
|
||||||
|
|
||||||
if (ps.includeMyRenotes === false) {
|
if (ps.includeMyRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.userId != :meId', { meId: user.id });
|
||||||
userId: { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.includeRenotedMyNotes === false) {
|
if (ps.includeRenotedMyNotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.renoteUserId != :meId', { meId: user.id });
|
||||||
'_renote.userId': { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.includeLocalRenotes === false) {
|
if (ps.includeLocalRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.renoteUserHost IS NOT NULL');
|
||||||
'_renote.user.host': { $ne: null }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if (ps.withFiles) {
|
if (ps.withFiles) {
|
||||||
query.andWhere('note.fileIds != \'{}\'');
|
query.andWhere('note.fileIds != \'{}\'');
|
||||||
|
|
|
@ -116,58 +116,35 @@ export default define(meta, async (ps, user) => {
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
generateMuteQuery(query, user);
|
generateMuteQuery(query, user);
|
||||||
|
|
||||||
/* v11 TODO
|
|
||||||
// MongoDBではトップレベルで否定ができないため、De Morganの法則を利用してクエリします。
|
|
||||||
// つまり、「『自分の投稿かつRenote』ではない」を「『自分の投稿ではない』または『Renoteではない』」と表現します。
|
|
||||||
// for details: https://en.wikipedia.org/wiki/De_Morgan%27s_laws
|
|
||||||
|
|
||||||
if (ps.includeMyRenotes === false) {
|
if (ps.includeMyRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.userId != :meId', { meId: user.id });
|
||||||
userId: { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.includeRenotedMyNotes === false) {
|
if (ps.includeRenotedMyNotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.renoteUserId != :meId', { meId: user.id });
|
||||||
'_renote.userId': { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.includeLocalRenotes === false) {
|
if (ps.includeLocalRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.renoteUserHost IS NOT NULL');
|
||||||
'_renote.user.host': { $ne: null }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
}
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (ps.withFiles) {
|
if (ps.withFiles) {
|
||||||
query.andWhere('note.fileIds != \'{}\'');
|
query.andWhere('note.fileIds != \'{}\'');
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { UserLists, UserListJoinings, Notes } from '../../../../models';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
|
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
|
||||||
import { activeUsersChart } from '../../../../services/chart';
|
import { activeUsersChart } from '../../../../services/chart';
|
||||||
|
import { Brackets } from 'typeorm';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -134,58 +135,35 @@ export default define(meta, async (ps, user) => {
|
||||||
|
|
||||||
generateVisibilityQuery(query, user);
|
generateVisibilityQuery(query, user);
|
||||||
|
|
||||||
/* TODO
|
|
||||||
// MongoDBではトップレベルで否定ができないため、De Morganの法則を利用してクエリします。
|
|
||||||
// つまり、「『自分の投稿かつRenote』ではない」を「『自分の投稿ではない』または『Renoteではない』」と表現します。
|
|
||||||
// for details: https://en.wikipedia.org/wiki/De_Morgan%27s_laws
|
|
||||||
|
|
||||||
if (ps.includeMyRenotes === false) {
|
if (ps.includeMyRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.userId != :meId', { meId: user.id });
|
||||||
userId: { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.includeRenotedMyNotes === false) {
|
if (ps.includeRenotedMyNotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.renoteUserId != :meId', { meId: user.id });
|
||||||
'_renote.userId': { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.includeLocalRenotes === false) {
|
if (ps.includeLocalRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.renoteUserHost IS NOT NULL');
|
||||||
'_renote.user.host': { $ne: null }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
}
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (ps.withFiles) {
|
if (ps.withFiles) {
|
||||||
query.andWhere('note.fileIds != \'{}\'');
|
query.andWhere('note.fileIds != \'{}\'');
|
||||||
|
|
|
@ -74,23 +74,7 @@ export const meta = {
|
||||||
validator: $.optional.bool,
|
validator: $.optional.bool,
|
||||||
default: true,
|
default: true,
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': '自分の行ったRenoteを含めるかどうか'
|
'ja-JP': 'Renoteを含めるかどうか'
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
includeRenotedMyNotes: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
default: true,
|
|
||||||
desc: {
|
|
||||||
'ja-JP': 'Renoteされた自分の投稿を含めるかどうか'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
includeLocalRenotes: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
default: true,
|
|
||||||
desc: {
|
|
||||||
'ja-JP': 'Renoteされたローカルの投稿を含めるかどうか'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -177,23 +161,15 @@ export default define(meta, async (ps, me) => {
|
||||||
query.andWhere('note.replyId IS NULL');
|
query.andWhere('note.replyId IS NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
|
||||||
if (ps.includeMyRenotes === false) {
|
if (ps.includeMyRenotes === false) {
|
||||||
query.$and.push({
|
query.andWhere(new Brackets(qb => {
|
||||||
$or: [{
|
qb.orWhere('note.userId != :userId', { userId: user.id });
|
||||||
userId: { $ne: user.id }
|
qb.orWhere('note.renoteId IS NULL');
|
||||||
}, {
|
qb.orWhere('note.text IS NOT NULL');
|
||||||
renoteId: null
|
qb.orWhere('note.fileIds != \'{}\'');
|
||||||
}, {
|
qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
|
||||||
text: { $ne: null }
|
}));
|
||||||
}, {
|
|
||||||
fileIds: { $ne: [] }
|
|
||||||
}, {
|
|
||||||
poll: { $ne: null }
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue