Drop stalk feature

Resolve #3935
Closes #2226
Closes #1946
This commit is contained in:
syuilo
2019-01-20 12:25:00 +09:00
parent d53d059480
commit 6909add1ec
12 changed files with 11 additions and 157 deletions

View File

@ -36,14 +36,12 @@ export const getFriends = async (me: mongodb.ObjectID, includeMe = true, remoteO
// ID list of other users who the I follows
const myfollowings = followings.map(following => ({
id: following.followeeId,
stalk: following.stalk
id: following.followeeId
}));
if (includeMe) {
myfollowings.push({
id: me,
stalk: true
id: me
});
}

View File

@ -1,50 +0,0 @@
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
import Following from '../../../../models/following';
import define from '../../define';
export const meta = {
desc: {
'ja-JP': '指定したユーザーをストーキングします。',
'en-US': 'Stalk a user.'
},
requireCredential: true,
kind: 'following-write',
params: {
userId: {
validator: $.type(ID),
transform: transform,
desc: {
'ja-JP': '対象のユーザーのID',
'en-US': 'Target user ID'
}
}
}
};
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
const follower = user;
// Fetch following
const following = await Following.findOne({
followerId: follower._id,
followeeId: ps.userId
});
if (following === null) {
return rej('following not found');
}
// Stalk
await Following.update({ _id: following._id }, {
$set: {
stalk: true
}
});
res();
// TODO: イベント
}));

View File

@ -1,50 +0,0 @@
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
import Following from '../../../../models/following';
import define from '../../define';
export const meta = {
desc: {
'ja-JP': '指定したユーザーのストーキングをやめます。',
'en-US': 'Unstalk a user.'
},
requireCredential: true,
kind: 'following-write',
params: {
userId: {
validator: $.type(ID),
transform: transform,
desc: {
'ja-JP': '対象のユーザーのID',
'en-US': 'Target user ID'
}
}
}
};
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
const follower = user;
// Fetch following
const following = await Following.findOne({
followerId: follower._id,
followeeId: ps.userId
});
if (following === null) {
return rej('following not found');
}
// Stalk
await Following.update({ _id: following._id }, {
$set: {
stalk: false
}
});
res();
// TODO: イベント
}));

View File

@ -119,12 +119,10 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
_id: -1
};
const followQuery = followings.map(f => f.stalk ? {
userId: f.id
} : {
const followQuery = followings.map(f => ({
userId: f.id,
// ストーキングしてないならリプライは含めない(ただし投稿者自身の投稿へのリプライ、自分の投稿へのリプライ、自分のリプライは含める)
// リプライは含めない(ただし投稿者自身の投稿へのリプライ、自分の投稿へのリプライ、自分のリプライは含める)
$or: [{
// リプライでない
replyId: null
@ -140,7 +138,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
// 自分(フォロワー)が送信したリプライ
userId: user._id
}]
});
}));
const visibleQuery = user == null ? [{
visibility: { $in: [ 'public', 'home' ] }

View File

@ -117,9 +117,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
_id: -1
};
const followQuery = followings.map(f => f.stalk ? {
userId: f.id
} : {
const followQuery = followings.map(f => ({
userId: f.id,
// ストーキングしてないならリプライは含めない(ただし投稿者自身の投稿へのリプライ、自分の投稿へのリプライ、自分のリプライは含める)
@ -138,7 +136,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
// 自分(フォロワー)が送信したリプライ
userId: user._id
}]
});
}));
const visibleQuery = user == null ? [{
visibility: { $in: [ 'public', 'home' ] }