summaryrefslogtreecommitdiff
path: root/src/api/endpoints/mute
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-28 16:39:14 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-28 16:39:14 +0900
commit3d5cdb8d2d60932caf1d29b0581c7d6243e06e37 (patch)
tree9c29d1062b08378d4c4cafe5976793616d45bc01 /src/api/endpoints/mute
parentwip (diff)
downloadsharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.gz
sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.bz2
sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.zip
wip
Diffstat (limited to 'src/api/endpoints/mute')
-rw-r--r--src/api/endpoints/mute/create.ts18
-rw-r--r--src/api/endpoints/mute/delete.ts14
-rw-r--r--src/api/endpoints/mute/list.ts8
3 files changed, 20 insertions, 20 deletions
diff --git a/src/api/endpoints/mute/create.ts b/src/api/endpoints/mute/create.ts
index f99b40d32e..e860235086 100644
--- a/src/api/endpoints/mute/create.ts
+++ b/src/api/endpoints/mute/create.ts
@@ -15,9 +15,9 @@ import Mute from '../../models/mute';
module.exports = (params, user) => new Promise(async (res, rej) => {
const muter = user;
- // Get 'user_id' parameter
- const [userId, userIdErr] = $(params.user_id).id().$;
- if (userIdErr) return rej('invalid user_id param');
+ // Get 'userId' parameter
+ const [userId, userIdErr] = $(params.userId).id().$;
+ if (userIdErr) return rej('invalid userId param');
// 自分自身
if (user._id.equals(userId)) {
@@ -40,9 +40,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Check if already muting
const exist = await Mute.findOne({
- muter_id: muter._id,
- mutee_id: mutee._id,
- deleted_at: { $exists: false }
+ muterId: muter._id,
+ muteeId: mutee._id,
+ deletedAt: { $exists: false }
});
if (exist !== null) {
@@ -51,9 +51,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Create mute
await Mute.insert({
- created_at: new Date(),
- muter_id: muter._id,
- mutee_id: mutee._id,
+ createdAt: new Date(),
+ muterId: muter._id,
+ muteeId: mutee._id,
});
// Send response
diff --git a/src/api/endpoints/mute/delete.ts b/src/api/endpoints/mute/delete.ts
index 36e2fd101a..7e361b4792 100644
--- a/src/api/endpoints/mute/delete.ts
+++ b/src/api/endpoints/mute/delete.ts
@@ -15,9 +15,9 @@ import Mute from '../../models/mute';
module.exports = (params, user) => new Promise(async (res, rej) => {
const muter = user;
- // Get 'user_id' parameter
- const [userId, userIdErr] = $(params.user_id).id().$;
- if (userIdErr) return rej('invalid user_id param');
+ // Get 'userId' parameter
+ const [userId, userIdErr] = $(params.userId).id().$;
+ if (userIdErr) return rej('invalid userId param');
// Check if the mutee is yourself
if (user._id.equals(userId)) {
@@ -40,9 +40,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Check not muting
const exist = await Mute.findOne({
- muter_id: muter._id,
- mutee_id: mutee._id,
- deleted_at: { $exists: false }
+ muterId: muter._id,
+ muteeId: mutee._id,
+ deletedAt: { $exists: false }
});
if (exist === null) {
@@ -54,7 +54,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
_id: exist._id
}, {
$set: {
- deleted_at: new Date()
+ deletedAt: new Date()
}
});
diff --git a/src/api/endpoints/mute/list.ts b/src/api/endpoints/mute/list.ts
index 19e3b157e6..3401fba64d 100644
--- a/src/api/endpoints/mute/list.ts
+++ b/src/api/endpoints/mute/list.ts
@@ -28,15 +28,15 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Construct query
const query = {
- muter_id: me._id,
- deleted_at: { $exists: false }
+ muterId: me._id,
+ deletedAt: { $exists: false }
} as any;
if (iknow) {
// Get my friends
const myFriends = await getFriends(me._id);
- query.mutee_id = {
+ query.muteeId = {
$in: myFriends
};
}
@@ -63,7 +63,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
const users = await Promise.all(mutes.map(async m =>
- await pack(m.mutee_id, me, { detail: true })));
+ await pack(m.muteeId, me, { detail: true })));
// Response
res({