fix: visibility
This commit is contained in:
parent
8fd4773260
commit
f6980ca040
2 changed files with 51 additions and 31 deletions
|
@ -163,8 +163,8 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
user.id,
|
user.id,
|
||||||
30,
|
30,
|
||||||
)) as ScyllaNotification[]
|
)) as ScyllaNotification[]
|
||||||
).slice(0, ps.limit);
|
);
|
||||||
return await Notifications.packMany(foundNotifications, user.id);
|
return (await Notifications.packMany(foundNotifications, user.id)).slice(0, ps.limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
const followingQuery = Followings.createQueryBuilder("following")
|
const followingQuery = Followings.createQueryBuilder("following")
|
||||||
|
|
|
@ -17,8 +17,10 @@ import {
|
||||||
scyllaClient,
|
scyllaClient,
|
||||||
} from "@/db/scylla.js";
|
} from "@/db/scylla.js";
|
||||||
import {
|
import {
|
||||||
|
ChannelFollowingsCache,
|
||||||
InstanceMutingsCache,
|
InstanceMutingsCache,
|
||||||
LocalFollowingsCache,
|
LocalFollowingsCache,
|
||||||
|
RenoteMutingsCache,
|
||||||
UserBlockedCache,
|
UserBlockedCache,
|
||||||
UserBlockingCache,
|
UserBlockingCache,
|
||||||
UserMutingsCache,
|
UserMutingsCache,
|
||||||
|
@ -84,28 +86,44 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scyllaClient) {
|
if (scyllaClient) {
|
||||||
const [
|
let [
|
||||||
|
followingChannelIds,
|
||||||
|
followingUserIds,
|
||||||
|
mutedUserIds,
|
||||||
|
mutedInstances,
|
||||||
|
blockerIds,
|
||||||
|
blockingIds,
|
||||||
|
renoteMutedIds,
|
||||||
|
]: string[][] = [];
|
||||||
|
let mutedWords: string[][];
|
||||||
|
if (me) {
|
||||||
|
[
|
||||||
|
followingChannelIds,
|
||||||
followingUserIds,
|
followingUserIds,
|
||||||
mutedUserIds,
|
mutedUserIds,
|
||||||
mutedInstances,
|
mutedInstances,
|
||||||
mutedWords,
|
mutedWords,
|
||||||
blockerIds,
|
blockerIds,
|
||||||
blockingIds,
|
blockingIds,
|
||||||
|
renoteMutedIds,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
LocalFollowingsCache.init(user.id).then((cache) => cache.getAll()),
|
ChannelFollowingsCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
UserMutingsCache.init(user.id).then((cache) => cache.getAll()),
|
LocalFollowingsCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
InstanceMutingsCache.init(user.id).then((cache) => cache.getAll()),
|
UserMutingsCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
|
InstanceMutingsCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
userWordMuteCache
|
userWordMuteCache
|
||||||
.fetchMaybe(user.id, () =>
|
.fetchMaybe(me.id, () =>
|
||||||
UserProfiles.findOne({
|
UserProfiles.findOne({
|
||||||
select: ["mutedWords"],
|
select: ["mutedWords"],
|
||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
}).then((profile) => profile?.mutedWords),
|
}).then((profile) => profile?.mutedWords),
|
||||||
)
|
)
|
||||||
.then((words) => words ?? []),
|
.then((words) => words ?? []),
|
||||||
UserBlockedCache.init(user.id).then((cache) => cache.getAll()),
|
UserBlockedCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
UserBlockingCache.init(user.id).then((cache) => cache.getAll()),
|
UserBlockingCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
|
RenoteMutingsCache.init(me.id).then((cache) => cache.getAll()),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mutedUserIds.includes(user.id) ||
|
mutedUserIds.includes(user.id) ||
|
||||||
|
@ -117,18 +135,20 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
|
|
||||||
const filter = async (notes: ScyllaNote[]) => {
|
const filter = async (notes: ScyllaNote[]) => {
|
||||||
let filtered = notes.filter((n) => n.userId === ps.userId);
|
let filtered = notes.filter((n) => n.userId === ps.userId);
|
||||||
filtered = await filterVisibility(filtered, user, followingUserIds);
|
filtered = await filterVisibility(filtered, me, followingUserIds);
|
||||||
|
if (me) {
|
||||||
filtered = await filterMutedUser(
|
filtered = await filterMutedUser(
|
||||||
filtered,
|
filtered,
|
||||||
user,
|
me,
|
||||||
mutedUserIds,
|
mutedUserIds,
|
||||||
mutedInstances,
|
mutedInstances,
|
||||||
);
|
);
|
||||||
filtered = await filterMutedNote(filtered, user, mutedWords);
|
filtered = await filterMutedNote(filtered, me, mutedWords);
|
||||||
filtered = await filterBlockUser(filtered, user, [
|
filtered = await filterBlockUser(filtered, me, [
|
||||||
...blockerIds,
|
...blockerIds,
|
||||||
...blockingIds,
|
...blockingIds,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
if (ps.withFiles) {
|
if (ps.withFiles) {
|
||||||
filtered = filtered.filter((n) => n.files.length > 0);
|
filtered = filtered.filter((n) => n.files.length > 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue