Compare commits
2 commits
08e3706df7
...
2991122668
Author | SHA1 | Date | |
---|---|---|---|
2991122668 | |||
d111fe935b |
6 changed files with 38 additions and 3 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
## 2024.9.2 (eGirlskey)
|
||||||
|
- Improvements to user block: posts should now get properly hidden if they are replies to or mentions of a blocked user.
|
||||||
|
|
||||||
## 2024.9.1 (eGirlskey)
|
## 2024.9.1 (eGirlskey)
|
||||||
- Impersonate `misskey` upstream in nodeinfo to fix issues with client apps
|
- Impersonate `misskey` upstream in nodeinfo to fix issues with client apps
|
||||||
- Fix two-factor-auth login with `secureApiMode: true` by returning a stub user to unauthorized clients.
|
- Fix two-factor-auth login with `secureApiMode: true` by returning a stub user to unauthorized clients.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "egirlskey",
|
"name": "egirlskey",
|
||||||
"version": "2024.9.1",
|
"version": "2024.9.2",
|
||||||
"codename": "boobdog",
|
"codename": "boobdog",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -70,27 +70,38 @@ export class QueryService {
|
||||||
// ここでいうBlockedは被Blockedの意
|
// ここでいうBlockedは被Blockedの意
|
||||||
@bindThis
|
@bindThis
|
||||||
public generateBlockedUserQuery(q: SelectQueryBuilder<any>, me: { id: MiUser['id'] }): void {
|
public generateBlockedUserQuery(q: SelectQueryBuilder<any>, me: { id: MiUser['id'] }): void {
|
||||||
|
const blockedQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
||||||
|
.select('blocking.blockeeId')
|
||||||
|
.where('blocking.blockerId = :blockerId', { blockerId: me.id });
|
||||||
|
|
||||||
const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
||||||
.select('blocking.blockerId')
|
.select('blocking.blockerId')
|
||||||
.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id });
|
.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id });
|
||||||
|
|
||||||
|
const mentionQuery = `SELECT COUNT(*) FROM unnest(note.mentions) mention WHERE mention IN (${blockingQuery.getQuery()}) OR mention IN (${blockedQuery.getQuery()}) LIMIT 1`;
|
||||||
|
|
||||||
// 投稿の作者にブロックされていない かつ
|
// 投稿の作者にブロックされていない かつ
|
||||||
// 投稿の返信先の作者にブロックされていない かつ
|
// 投稿の返信先の作者にブロックされていない かつ
|
||||||
// 投稿の引用元の作者にブロックされていない
|
// 投稿の引用元の作者にブロックされていない
|
||||||
q
|
q
|
||||||
.andWhere(`note.userId NOT IN (${ blockingQuery.getQuery() })`)
|
.andWhere(`note.userId NOT IN (${ blockingQuery.getQuery() })`)
|
||||||
|
.andWhere(`note.userId NOT IN (${ blockedQuery.getQuery() })`)
|
||||||
.andWhere(new Brackets(qb => {
|
.andWhere(new Brackets(qb => {
|
||||||
qb
|
qb
|
||||||
.where('note.replyUserId IS NULL')
|
.where('note.replyUserId IS NULL')
|
||||||
|
.orWhere(`note.replyUserId NOT IN (${ blockedQuery.getQuery() })`)
|
||||||
.orWhere(`note.replyUserId NOT IN (${ blockingQuery.getQuery() })`);
|
.orWhere(`note.replyUserId NOT IN (${ blockingQuery.getQuery() })`);
|
||||||
}))
|
}))
|
||||||
.andWhere(new Brackets(qb => {
|
.andWhere(new Brackets(qb => {
|
||||||
qb
|
qb
|
||||||
.where('note.renoteUserId IS NULL')
|
.where('note.renoteUserId IS NULL')
|
||||||
|
.orWhere(`note.renoteUserId NOT IN (${ blockedQuery.getQuery() })`)
|
||||||
.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`);
|
.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`);
|
||||||
}));
|
}))
|
||||||
|
.andWhere(`(${mentionQuery}) = 0`);
|
||||||
|
|
||||||
q.setParameters(blockingQuery.getParameters());
|
q.setParameters(blockingQuery.getParameters());
|
||||||
|
q.setParameters(blockedQuery.getParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean {
|
export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean {
|
||||||
|
console.log(note);
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -20,5 +22,13 @@ export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = fa
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ignoreAuthor && note.mentions != null && note.mentions.some(mention => userIds.has(mention))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ignoreAuthor && note.renote != null && note.renote.mentions != null && note.renote.mentions.some(mention => userIds.has(mention))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ export default class Connection {
|
||||||
public followingChannels: Set<string> = new Set();
|
public followingChannels: Set<string> = new Set();
|
||||||
public userIdsWhoMeMuting: Set<string> = new Set();
|
public userIdsWhoMeMuting: Set<string> = new Set();
|
||||||
public userIdsWhoBlockingMe: Set<string> = new Set();
|
public userIdsWhoBlockingMe: Set<string> = new Set();
|
||||||
|
public userIdsWhoMeBlocking: Set<string> = new Set();
|
||||||
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
|
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
|
||||||
public userMutedInstances: Set<string> = new Set();
|
public userMutedInstances: Set<string> = new Set();
|
||||||
private fetchIntervalId: NodeJS.Timeout | null = null;
|
private fetchIntervalId: NodeJS.Timeout | null = null;
|
||||||
|
@ -72,12 +73,13 @@ export default class Connection {
|
||||||
@bindThis
|
@bindThis
|
||||||
public async fetch() {
|
public async fetch() {
|
||||||
if (this.user == null) return;
|
if (this.user == null) return;
|
||||||
const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes] = await Promise.all([
|
const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeBlocking, userIdsWhoMeMutingRenotes] = await Promise.all([
|
||||||
this.cacheService.userProfileCache.fetch(this.user.id),
|
this.cacheService.userProfileCache.fetch(this.user.id),
|
||||||
this.cacheService.userFollowingsCache.fetch(this.user.id),
|
this.cacheService.userFollowingsCache.fetch(this.user.id),
|
||||||
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
|
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
|
||||||
this.cacheService.userMutingsCache.fetch(this.user.id),
|
this.cacheService.userMutingsCache.fetch(this.user.id),
|
||||||
this.cacheService.userBlockedCache.fetch(this.user.id),
|
this.cacheService.userBlockedCache.fetch(this.user.id),
|
||||||
|
this.cacheService.userBlockingCache.fetch(this.user.id),
|
||||||
this.cacheService.renoteMutingsCache.fetch(this.user.id),
|
this.cacheService.renoteMutingsCache.fetch(this.user.id),
|
||||||
]);
|
]);
|
||||||
this.userProfile = userProfile;
|
this.userProfile = userProfile;
|
||||||
|
@ -85,6 +87,7 @@ export default class Connection {
|
||||||
this.followingChannels = followingChannels;
|
this.followingChannels = followingChannels;
|
||||||
this.userIdsWhoMeMuting = userIdsWhoMeMuting;
|
this.userIdsWhoMeMuting = userIdsWhoMeMuting;
|
||||||
this.userIdsWhoBlockingMe = userIdsWhoBlockingMe;
|
this.userIdsWhoBlockingMe = userIdsWhoBlockingMe;
|
||||||
|
this.userIdsWhoMeBlocking = userIdsWhoMeBlocking;
|
||||||
this.userIdsWhoMeMutingRenotes = userIdsWhoMeMutingRenotes;
|
this.userIdsWhoMeMutingRenotes = userIdsWhoMeMutingRenotes;
|
||||||
this.userMutedInstances = new Set(userProfile.mutedInstances);
|
this.userMutedInstances = new Set(userProfile.mutedInstances);
|
||||||
}
|
}
|
||||||
|
@ -253,6 +256,9 @@ export default class Connection {
|
||||||
if (this.userIdsWhoBlockingMe.has(noteUserId)) {
|
if (this.userIdsWhoBlockingMe.has(noteUserId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.userIdsWhoMeBlocking.has(noteUserId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,10 @@ export default abstract class Channel {
|
||||||
return this.connection.userIdsWhoBlockingMe;
|
return this.connection.userIdsWhoBlockingMe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected get userIdsWhoMeBlocking() {
|
||||||
|
return this.connection.userIdsWhoMeBlocking;
|
||||||
|
}
|
||||||
|
|
||||||
protected get userMutedInstances() {
|
protected get userMutedInstances() {
|
||||||
return this.connection.userMutedInstances;
|
return this.connection.userMutedInstances;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +74,7 @@ export default abstract class Channel {
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return true;
|
if (isUserRelated(note, this.userIdsWhoMeMuting)) return true;
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わる
|
// 流れてきたNoteがブロックされているユーザーが関わる
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
|
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
|
||||||
|
if (isUserRelated(note, this.userIdsWhoMeBlocking)) return true;
|
||||||
|
|
||||||
// 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
|
// 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
|
||||||
if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
|
if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue