summaryrefslogtreecommitdiff
path: root/src/api/endpoints/i
diff options
context:
space:
mode:
authorAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-29 01:20:40 +0900
committerAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-29 01:54:41 +0900
commit90f8fe7e538bb7e52d2558152a0390e693f39b11 (patch)
tree0f830887053c8f352b1cd0c13ca715fd14c1f030 /src/api/endpoints/i
parentImplement remote account resolution (diff)
downloadsharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.gz
sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.bz2
sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.zip
Introduce processor
Diffstat (limited to 'src/api/endpoints/i')
-rw-r--r--src/api/endpoints/i/2fa/done.ts37
-rw-r--r--src/api/endpoints/i/2fa/register.ts48
-rw-r--r--src/api/endpoints/i/2fa/unregister.ts28
-rw-r--r--src/api/endpoints/i/appdata/get.ts39
-rw-r--r--src/api/endpoints/i/appdata/set.ts58
-rw-r--r--src/api/endpoints/i/authorized_apps.ts43
-rw-r--r--src/api/endpoints/i/change_password.ts42
-rw-r--r--src/api/endpoints/i/favorites.ts44
-rw-r--r--src/api/endpoints/i/notifications.ts110
-rw-r--r--src/api/endpoints/i/pin.ts44
-rw-r--r--src/api/endpoints/i/regenerate_token.ts42
-rw-r--r--src/api/endpoints/i/signin_history.ts61
-rw-r--r--src/api/endpoints/i/update.ts97
-rw-r--r--src/api/endpoints/i/update_client_setting.ts43
-rw-r--r--src/api/endpoints/i/update_home.ts60
-rw-r--r--src/api/endpoints/i/update_mobile_home.ts59
16 files changed, 0 insertions, 855 deletions
diff --git a/src/api/endpoints/i/2fa/done.ts b/src/api/endpoints/i/2fa/done.ts
deleted file mode 100644
index 0f1db73829..0000000000
--- a/src/api/endpoints/i/2fa/done.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import * as speakeasy from 'speakeasy';
-import User from '../../../models/user';
-
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'token' parameter
- const [token, tokenErr] = $(params.token).string().$;
- if (tokenErr) return rej('invalid token param');
-
- const _token = token.replace(/\s/g, '');
-
- if (user.two_factor_temp_secret == null) {
- return rej('二段階認証の設定が開始されていません');
- }
-
- const verified = (speakeasy as any).totp.verify({
- secret: user.two_factor_temp_secret,
- encoding: 'base32',
- token: _token
- });
-
- if (!verified) {
- return rej('not verified');
- }
-
- await User.update(user._id, {
- $set: {
- 'account.two_factor_secret': user.two_factor_temp_secret,
- 'account.two_factor_enabled': true
- }
- });
-
- res();
-});
diff --git a/src/api/endpoints/i/2fa/register.ts b/src/api/endpoints/i/2fa/register.ts
deleted file mode 100644
index 24abfcdfc5..0000000000
--- a/src/api/endpoints/i/2fa/register.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import * as speakeasy from 'speakeasy';
-import * as QRCode from 'qrcode';
-import User from '../../../models/user';
-import config from '../../../../conf';
-
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'password' parameter
- const [password, passwordErr] = $(params.password).string().$;
- if (passwordErr) return rej('invalid password param');
-
- // Compare password
- const same = await bcrypt.compare(password, user.account.password);
-
- if (!same) {
- return rej('incorrect password');
- }
-
- // Generate user's secret key
- const secret = speakeasy.generateSecret({
- length: 32
- });
-
- await User.update(user._id, {
- $set: {
- two_factor_temp_secret: secret.base32
- }
- });
-
- // Get the data URL of the authenticator URL
- QRCode.toDataURL(speakeasy.otpauthURL({
- secret: secret.base32,
- encoding: 'base32',
- label: user.username,
- issuer: config.host
- }), (err, data_url) => {
- res({
- qr: data_url,
- secret: secret.base32,
- label: user.username,
- issuer: config.host
- });
- });
-});
diff --git a/src/api/endpoints/i/2fa/unregister.ts b/src/api/endpoints/i/2fa/unregister.ts
deleted file mode 100644
index c43f9ccc44..0000000000
--- a/src/api/endpoints/i/2fa/unregister.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import User from '../../../models/user';
-
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'password' parameter
- const [password, passwordErr] = $(params.password).string().$;
- if (passwordErr) return rej('invalid password param');
-
- // Compare password
- const same = await bcrypt.compare(password, user.account.password);
-
- if (!same) {
- return rej('incorrect password');
- }
-
- await User.update(user._id, {
- $set: {
- 'account.two_factor_secret': null,
- 'account.two_factor_enabled': false
- }
- });
-
- res();
-});
diff --git a/src/api/endpoints/i/appdata/get.ts b/src/api/endpoints/i/appdata/get.ts
deleted file mode 100644
index 571208d46c..0000000000
--- a/src/api/endpoints/i/appdata/get.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import Appdata from '../../../models/appdata';
-
-/**
- * Get app data
- *
- * @param {any} params
- * @param {any} user
- * @param {any} app
- * @param {Boolean} isSecure
- * @return {Promise<any>}
- */
-module.exports = (params, user, app) => new Promise(async (res, rej) => {
- if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます');
-
- // Get 'key' parameter
- const [key = null, keyError] = $(params.key).optional.nullable.string().match(/[a-z_]+/).$;
- if (keyError) return rej('invalid key param');
-
- const select = {};
- if (key !== null) {
- select[`data.${key}`] = true;
- }
- const appdata = await Appdata.findOne({
- app_id: app._id,
- user_id: user._id
- }, {
- fields: select
- });
-
- if (appdata) {
- res(appdata.data);
- } else {
- res();
- }
-});
diff --git a/src/api/endpoints/i/appdata/set.ts b/src/api/endpoints/i/appdata/set.ts
deleted file mode 100644
index 2804a14cb3..0000000000
--- a/src/api/endpoints/i/appdata/set.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import Appdata from '../../../models/appdata';
-
-/**
- * Set app data
- *
- * @param {any} params
- * @param {any} user
- * @param {any} app
- * @param {Boolean} isSecure
- * @return {Promise<any>}
- */
-module.exports = (params, user, app) => new Promise(async (res, rej) => {
- if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます');
-
- // Get 'data' parameter
- const [data, dataError] = $(params.data).optional.object()
- .pipe(obj => {
- const hasInvalidData = Object.entries(obj).some(([k, v]) =>
- $(k).string().match(/^[a-z_]+$/).nok() && $(v).string().nok());
- return !hasInvalidData;
- }).$;
- if (dataError) return rej('invalid data param');
-
- // Get 'key' parameter
- const [key, keyError] = $(params.key).optional.string().match(/[a-z_]+/).$;
- if (keyError) return rej('invalid key param');
-
- // Get 'value' parameter
- const [value, valueError] = $(params.value).optional.string().$;
- if (valueError) return rej('invalid value param');
-
- const set = {};
- if (data) {
- Object.entries(data).forEach(([k, v]) => {
- set[`data.${k}`] = v;
- });
- } else {
- set[`data.${key}`] = value;
- }
-
- await Appdata.update({
- app_id: app._id,
- user_id: user._id
- }, Object.assign({
- app_id: app._id,
- user_id: user._id
- }, {
- $set: set
- }), {
- upsert: true
- });
-
- res(204);
-});
diff --git a/src/api/endpoints/i/authorized_apps.ts b/src/api/endpoints/i/authorized_apps.ts
deleted file mode 100644
index 40ce7a68c8..0000000000
--- a/src/api/endpoints/i/authorized_apps.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import AccessToken from '../../models/access-token';
-import { pack } from '../../models/app';
-
-/**
- * Get authorized apps of my account
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'limit' parameter
- const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
- if (limitErr) return rej('invalid limit param');
-
- // Get 'offset' parameter
- const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$;
- if (offsetErr) return rej('invalid offset param');
-
- // Get 'sort' parameter
- const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$;
- if (sortError) return rej('invalid sort param');
-
- // Get tokens
- const tokens = await AccessToken
- .find({
- user_id: user._id
- }, {
- limit: limit,
- skip: offset,
- sort: {
- _id: sort == 'asc' ? 1 : -1
- }
- });
-
- // Serialize
- res(await Promise.all(tokens.map(async token =>
- await pack(token.app_id))));
-});
diff --git a/src/api/endpoints/i/change_password.ts b/src/api/endpoints/i/change_password.ts
deleted file mode 100644
index 88fb36b1fb..0000000000
--- a/src/api/endpoints/i/change_password.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import User from '../../models/user';
-
-/**
- * Change password
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'current_password' parameter
- const [currentPassword, currentPasswordErr] = $(params.current_password).string().$;
- if (currentPasswordErr) return rej('invalid current_password param');
-
- // Get 'new_password' parameter
- const [newPassword, newPasswordErr] = $(params.new_password).string().$;
- if (newPasswordErr) return rej('invalid new_password param');
-
- // Compare password
- const same = await bcrypt.compare(currentPassword, user.account.password);
-
- if (!same) {
- return rej('incorrect password');
- }
-
- // Generate hash of password
- const salt = await bcrypt.genSalt(8);
- const hash = await bcrypt.hash(newPassword, salt);
-
- await User.update(user._id, {
- $set: {
- 'account.password': hash
- }
- });
-
- res();
-});
diff --git a/src/api/endpoints/i/favorites.ts b/src/api/endpoints/i/favorites.ts
deleted file mode 100644
index eb464cf0f0..0000000000
--- a/src/api/endpoints/i/favorites.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import Favorite from '../../models/favorite';
-import { pack } from '../../models/post';
-
-/**
- * Get followers of a user
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'limit' parameter
- const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
- if (limitErr) return rej('invalid limit param');
-
- // Get 'offset' parameter
- const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$;
- if (offsetErr) return rej('invalid offset param');
-
- // Get 'sort' parameter
- const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$;
- if (sortError) return rej('invalid sort param');
-
- // Get favorites
- const favorites = await Favorite
- .find({
- user_id: user._id
- }, {
- limit: limit,
- skip: offset,
- sort: {
- _id: sort == 'asc' ? 1 : -1
- }
- });
-
- // Serialize
- res(await Promise.all(favorites.map(async favorite =>
- await pack(favorite.post)
- )));
-});
diff --git a/src/api/endpoints/i/notifications.ts b/src/api/endpoints/i/notifications.ts
deleted file mode 100644
index 688039a0dd..0000000000
--- a/src/api/endpoints/i/notifications.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import Notification from '../../models/notification';
-import Mute from '../../models/mute';
-import { pack } from '../../models/notification';
-import getFriends from '../../common/get-friends';
-import read from '../../common/read-notification';
-
-/**
- * Get notifications
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'following' parameter
- const [following = false, followingError] =
- $(params.following).optional.boolean().$;
- if (followingError) return rej('invalid following param');
-
- // Get 'mark_as_read' parameter
- const [markAsRead = true, markAsReadErr] = $(params.mark_as_read).optional.boolean().$;
- if (markAsReadErr) return rej('invalid mark_as_read param');
-
- // Get 'type' parameter
- const [type, typeErr] = $(params.type).optional.array('string').unique().$;
- if (typeErr) return rej('invalid type param');
-
- // Get 'limit' parameter
- const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
- if (limitErr) return rej('invalid limit param');
-
- // Get 'since_id' parameter
- const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
- if (sinceIdErr) return rej('invalid since_id param');
-
- // Get 'until_id' parameter
- const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
- if (untilIdErr) return rej('invalid until_id param');
-
- // Check if both of since_id and until_id is specified
- if (sinceId && untilId) {
- return rej('cannot set since_id and until_id');
- }
-
- const mute = await Mute.find({
- muter_id: user._id,
- deleted_at: { $exists: false }
- });
-
- const query = {
- notifiee_id: user._id,
- $and: [{
- notifier_id: {
- $nin: mute.map(m => m.mutee_id)
- }
- }]
- } as any;
-
- const sort = {
- _id: -1
- };
-
- if (following) {
- // ID list of the user itself and other users who the user follows
- const followingIds = await getFriends(user._id);
-
- query.$and.push({
- notifier_id: {
- $in: followingIds
- }
- });
- }
-
- if (type) {
- query.type = {
- $in: type
- };
- }
-
- if (sinceId) {
- sort._id = 1;
- query._id = {
- $gt: sinceId
- };
- } else if (untilId) {
- query._id = {
- $lt: untilId
- };
- }
-
- // Issue query
- const notifications = await Notification
- .find(query, {
- limit: limit,
- sort: sort
- });
-
- // Serialize
- res(await Promise.all(notifications.map(async notification =>
- await pack(notification))));
-
- // Mark as read all
- if (notifications.length > 0 && markAsRead) {
- read(user._id, notifications);
- }
-});
diff --git a/src/api/endpoints/i/pin.ts b/src/api/endpoints/i/pin.ts
deleted file mode 100644
index ff546fc2bd..0000000000
--- a/src/api/endpoints/i/pin.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import User from '../../models/user';
-import Post from '../../models/post';
-import { pack } from '../../models/user';
-
-/**
- * Pin post
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'post_id' parameter
- const [postId, postIdErr] = $(params.post_id).id().$;
- if (postIdErr) return rej('invalid post_id param');
-
- // Fetch pinee
- const post = await Post.findOne({
- _id: postId,
- user_id: user._id
- });
-
- if (post === null) {
- return rej('post not found');
- }
-
- await User.update(user._id, {
- $set: {
- pinned_post_id: post._id
- }
- });
-
- // Serialize
- const iObj = await pack(user, user, {
- detail: true
- });
-
- // Send response
- res(iObj);
-});
diff --git a/src/api/endpoints/i/regenerate_token.ts b/src/api/endpoints/i/regenerate_token.ts
deleted file mode 100644
index 9ac7b55071..0000000000
--- a/src/api/endpoints/i/regenerate_token.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import User from '../../models/user';
-import event from '../../event';
-import generateUserToken from '../../common/generate-native-user-token';
-
-/**
- * Regenerate native token
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'password' parameter
- const [password, passwordErr] = $(params.password).string().$;
- if (passwordErr) return rej('invalid password param');
-
- // Compare password
- const same = await bcrypt.compare(password, user.account.password);
-
- if (!same) {
- return rej('incorrect password');
- }
-
- // Generate secret
- const secret = generateUserToken();
-
- await User.update(user._id, {
- $set: {
- 'account.token': secret
- }
- });
-
- res();
-
- // Publish event
- event(user._id, 'my_token_regenerated');
-});
diff --git a/src/api/endpoints/i/signin_history.ts b/src/api/endpoints/i/signin_history.ts
deleted file mode 100644
index 859e81653d..0000000000
--- a/src/api/endpoints/i/signin_history.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import Signin, { pack } from '../../models/signin';
-
-/**
- * Get signin history of my account
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'limit' parameter
- const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
- if (limitErr) return rej('invalid limit param');
-
- // Get 'since_id' parameter
- const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
- if (sinceIdErr) return rej('invalid since_id param');
-
- // Get 'until_id' parameter
- const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
- if (untilIdErr) return rej('invalid until_id param');
-
- // Check if both of since_id and until_id is specified
- if (sinceId && untilId) {
- return rej('cannot set since_id and until_id');
- }
-
- const query = {
- user_id: user._id
- } as any;
-
- const sort = {
- _id: -1
- };
-
- if (sinceId) {
- sort._id = 1;
- query._id = {
- $gt: sinceId
- };
- } else if (untilId) {
- query._id = {
- $lt: untilId
- };
- }
-
- // Issue query
- const history = await Signin
- .find(query, {
- limit: limit,
- sort: sort
- });
-
- // Serialize
- res(await Promise.all(history.map(async record =>
- await pack(record))));
-});
diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
deleted file mode 100644
index db8a3f25bd..0000000000
--- a/src/api/endpoints/i/update.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../models/user';
-import event from '../../event';
-import config from '../../../conf';
-
-/**
- * Update myself
- *
- * @param {any} params
- * @param {any} user
- * @param {any} _
- * @param {boolean} isSecure
- * @return {Promise<any>}
- */
-module.exports = async (params, user, _, isSecure) => new Promise(async (res, rej) => {
- // Get 'name' parameter
- const [name, nameErr] = $(params.name).optional.string().pipe(isValidName).$;
- if (nameErr) return rej('invalid name param');
- if (name) user.name = name;
-
- // Get 'description' parameter
- const [description, descriptionErr] = $(params.description).optional.nullable.string().pipe(isValidDescription).$;
- if (descriptionErr) return rej('invalid description param');
- if (description !== undefined) user.description = description;
-
- // Get 'location' parameter
- const [location, locationErr] = $(params.location).optional.nullable.string().pipe(isValidLocation).$;
- if (locationErr) return rej('invalid location param');
- if (location !== undefined) user.account.profile.location = location;
-
- // Get 'birthday' parameter
- const [birthday, birthdayErr] = $(params.birthday).optional.nullable.string().pipe(isValidBirthday).$;
- if (birthdayErr) return rej('invalid birthday param');
- if (birthday !== undefined) user.account.profile.birthday = birthday;
-
- // Get 'avatar_id' parameter
- const [avatarId, avatarIdErr] = $(params.avatar_id).optional.id().$;
- if (avatarIdErr) return rej('invalid avatar_id param');
- if (avatarId) user.avatar_id = avatarId;
-
- // Get 'banner_id' parameter
- const [bannerId, bannerIdErr] = $(params.banner_id).optional.id().$;
- if (bannerIdErr) return rej('invalid banner_id param');
- if (bannerId) user.banner_id = bannerId;
-
- // Get 'is_bot' parameter
- const [isBot, isBotErr] = $(params.is_bot).optional.boolean().$;
- if (isBotErr) return rej('invalid is_bot param');
- if (isBot != null) user.account.is_bot = isBot;
-
- // Get 'auto_watch' parameter
- const [autoWatch, autoWatchErr] = $(params.auto_watch).optional.boolean().$;
- if (autoWatchErr) return rej('invalid auto_watch param');
- if (autoWatch != null) user.account.settings.auto_watch = autoWatch;
-
- await User.update(user._id, {
- $set: {
- name: user.name,
- description: user.description,
- avatar_id: user.avatar_id,
- banner_id: user.banner_id,
- 'account.profile': user.account.profile,
- 'account.is_bot': user.account.is_bot,
- 'account.settings': user.account.settings
- }
- });
-
- // Serialize
- const iObj = await pack(user, user, {
- detail: true,
- includeSecrets: isSecure
- });
-
- // Send response
- res(iObj);
-
- // Publish i updated event
- event(user._id, 'i_updated', iObj);
-
- // Update search index
- if (config.elasticsearch.enable) {
- const es = require('../../../db/elasticsearch');
-
- es.index({
- index: 'misskey',
- type: 'user',
- id: user._id.toString(),
- body: {
- name: user.name,
- bio: user.bio
- }
- });
- }
-});
diff --git a/src/api/endpoints/i/update_client_setting.ts b/src/api/endpoints/i/update_client_setting.ts
deleted file mode 100644
index c772ed5dc3..0000000000
--- a/src/api/endpoints/i/update_client_setting.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import User, { pack } from '../../models/user';
-import event from '../../event';
-
-/**
- * Update myself
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'name' parameter
- const [name, nameErr] = $(params.name).string().$;
- if (nameErr) return rej('invalid name param');
-
- // Get 'value' parameter
- const [value, valueErr] = $(params.value).nullable.any().$;
- if (valueErr) return rej('invalid value param');
-
- const x = {};
- x[`account.client_settings.${name}`] = value;
-
- await User.update(user._id, {
- $set: x
- });
-
- // Serialize
- user.account.client_settings[name] = value;
- const iObj = await pack(user, user, {
- detail: true,
- includeSecrets: true
- });
-
- // Send response
- res(iObj);
-
- // Publish i updated event
- event(user._id, 'i_updated', iObj);
-});
diff --git a/src/api/endpoints/i/update_home.ts b/src/api/endpoints/i/update_home.ts
deleted file mode 100644
index 9ce44e25ee..0000000000
--- a/src/api/endpoints/i/update_home.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import User from '../../models/user';
-import event from '../../event';
-
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'home' parameter
- const [home, homeErr] = $(params.home).optional.array().each(
- $().strict.object()
- .have('name', $().string())
- .have('id', $().string())
- .have('place', $().string())
- .have('data', $().object())).$;
- if (homeErr) return rej('invalid home param');
-
- // Get 'id' parameter
- const [id, idErr] = $(params.id).optional.string().$;
- if (idErr) return rej('invalid id param');
-
- // Get 'data' parameter
- const [data, dataErr] = $(params.data).optional.object().$;
- if (dataErr) return rej('invalid data param');
-
- if (home) {
- await User.update(user._id, {
- $set: {
- 'account.client_settings.home': home
- }
- });
-
- res();
-
- event(user._id, 'home_updated', {
- home
- });
- } else {
- if (id == null && data == null) return rej('you need to set id and data params if home param unset');
-
- const _home = user.account.client_settings.home;
- const widget = _home.find(w => w.id == id);
-
- if (widget == null) return rej('widget not found');
-
- widget.data = data;
-
- await User.update(user._id, {
- $set: {
- 'account.client_settings.home': _home
- }
- });
-
- res();
-
- event(user._id, 'home_updated', {
- id, data
- });
- }
-});
diff --git a/src/api/endpoints/i/update_mobile_home.ts b/src/api/endpoints/i/update_mobile_home.ts
deleted file mode 100644
index 1daddf42b9..0000000000
--- a/src/api/endpoints/i/update_mobile_home.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import User from '../../models/user';
-import event from '../../event';
-
-module.exports = async (params, user) => new Promise(async (res, rej) => {
- // Get 'home' parameter
- const [home, homeErr] = $(params.home).optional.array().each(
- $().strict.object()
- .have('name', $().string())
- .have('id', $().string())
- .have('data', $().object())).$;
- if (homeErr) return rej('invalid home param');
-
- // Get 'id' parameter
- const [id, idErr] = $(params.id).optional.string().$;
- if (idErr) return rej('invalid id param');
-
- // Get 'data' parameter
- const [data, dataErr] = $(params.data).optional.object().$;
- if (dataErr) return rej('invalid data param');
-
- if (home) {
- await User.update(user._id, {
- $set: {
- 'account.client_settings.mobile_home': home
- }
- });
-
- res();
-
- event(user._id, 'mobile_home_updated', {
- home
- });
- } else {
- if (id == null && data == null) return rej('you need to set id and data params if home param unset');
-
- const _home = user.account.client_settings.mobile_home || [];
- const widget = _home.find(w => w.id == id);
-
- if (widget == null) return rej('widget not found');
-
- widget.data = data;
-
- await User.update(user._id, {
- $set: {
- 'account.client_settings.mobile_home': _home
- }
- });
-
- res();
-
- event(user._id, 'mobile_home_updated', {
- id, data
- });
- }
-});