Skip to content

Commit

Permalink
サイレンスは表示時に除外するように
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Nov 17, 2019
1 parent 7530f44 commit e17ce75
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/server/api/common/get-hide-users.ts
Expand Up @@ -17,7 +17,8 @@ export async function getHideUserIdsById(meId?: mongo.ObjectID, includeSilenced
}
}),
includeSilenced ? (User.find({
isSilenced: true
isSilenced: true,
_id: { $nin: meId ? [ meId ] : [] }
}, {
fields: {
_id: true
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/notes/featured.ts
Expand Up @@ -42,7 +42,7 @@ export const meta = {
export default define(meta, async (ps, user) => {
const day = 1000 * 60 * 60 * 24 * ps.days;

const hideUserIds = await getHideUserIds(user);
const hideUserIds = await getHideUserIds(user, true);

const notes = await Note.find({
createdAt: {
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/notes/global-timeline.ts
Expand Up @@ -102,7 +102,7 @@ export default define(meta, async (ps, user) => {
}

// 隠すユーザーを取得
const hideUserIds = await getHideUserIds(user);
const hideUserIds = await getHideUserIds(user, true);

//#region Construct query
const sort = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/notes/hybrid-timeline.ts
Expand Up @@ -149,7 +149,7 @@ export default define(meta, async (ps, user) => {
getFriends(user._id, true, false),

// 隠すユーザーを取得
getHideUserIds(user),
getHideUserIds(user, true),

// Homeから隠すリストを取得
UserList.find({
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/notes/local-timeline.ts
Expand Up @@ -127,7 +127,7 @@ export default define(meta, async (ps, user) => {
}

// 隠すユーザーを取得
const hideUserIds = await getHideUserIds(user);
const hideUserIds = await getHideUserIds(user, true);

//#region Construct query
const sort = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/notes/polls/recommendation.ts
Expand Up @@ -47,7 +47,7 @@ export default define(meta, async (ps, user) => {
}) as any as mongo.ObjectID[];

// 隠すユーザーを取得
const hideUserIds = await getHideUserIds(user);
const hideUserIds = await getHideUserIds(user, true);

const notes = await Note.find({
_id: {
Expand Down
8 changes: 8 additions & 0 deletions src/server/api/stream/channels/global-timeline.ts
Expand Up @@ -4,6 +4,7 @@ import { pack } from '../../../../models/note';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
import User from '../../../../models/user';

export default class extends Channel {
public readonly chName = 'globalTimeline';
Expand All @@ -24,6 +25,13 @@ export default class extends Channel {

const mute = await Mute.find({ muterId: this.user._id });
this.mutedUserIds = mute.map(m => m.muteeId.toString());

const silences = await User.find({
isSilenced: true,
_id: { $nin: this.user ? [ this.user._id ] : [] }
});

this.mutedUserIds = this.mutedUserIds.concat(silences.map(x => x._id.toString()));
}

@autobind
Expand Down
8 changes: 8 additions & 0 deletions src/server/api/stream/channels/hybrid-timeline.ts
Expand Up @@ -7,6 +7,7 @@ import fetchMeta from '../../../../misc/fetch-meta';
import UserList from '../../../../models/user-list';
import { concat } from '../../../../prelude/array';
import { isSelfHost } from '../../../../misc/convert-host';
import User from '../../../../models/user';

export default class extends Channel {
public readonly chName = 'hybridTimeline';
Expand All @@ -29,6 +30,13 @@ export default class extends Channel {
const mute = await Mute.find({ muterId: this.user._id });
this.mutedUserIds = mute.map(m => m.muteeId.toString());

const silences = await User.find({
isSilenced: true,
_id: { $nin: this.user ? [ this.user._id ] : [] }
});

this.mutedUserIds = this.mutedUserIds.concat(silences.map(x => x._id.toString()));

// Homeから隠すリストユーザー
const lists = await UserList.find({
userId: this.user._id,
Expand Down
8 changes: 8 additions & 0 deletions src/server/api/stream/channels/local-timeline.ts
Expand Up @@ -4,6 +4,7 @@ import { pack } from '../../../../models/note';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
import User from '../../../../models/user';

export default class extends Channel {
public readonly chName = 'localTimeline';
Expand All @@ -24,6 +25,13 @@ export default class extends Channel {

const mute = this.user ? await Mute.find({ muterId: this.user._id }) : null;
this.mutedUserIds = mute ? mute.map(m => m.muteeId.toString()) : [];

const silences = await User.find({
isSilenced: true,
_id: { $nin: this.user ? [ this.user._id ] : [] }
});

this.mutedUserIds = this.mutedUserIds.concat(silences.map(x => x._id.toString()));
}

@autobind
Expand Down
5 changes: 0 additions & 5 deletions src/services/note/create.ts
Expand Up @@ -122,11 +122,6 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
if (data.viaMobile == null) data.viaMobile = false;
if (data.localOnly == null) data.localOnly = false;

// サイレンス
if (user.isSilenced && data.visibility == 'public') {
data.visibility = 'home';
}

if (data.visibleUsers) {
data.visibleUsers = erase(null, data.visibleUsers);
}
Expand Down

0 comments on commit e17ce75

Please sign in to comment.