summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-02-23 02:13:40 +0900
committerGitHub <noreply@github.com>2018-02-23 02:13:40 +0900
commitd1785848289397b9e8242edd9bd87c5906fe5eb7 (patch)
tree8cb4ff23a694f95bc8f4895698b6202090c26554 /src/api
parentMerge pull request #1097 from syuilo/refactor (diff)
parentwip (diff)
downloadmisskey-d1785848289397b9e8242edd9bd87c5906fe5eb7.tar.gz
misskey-d1785848289397b9e8242edd9bd87c5906fe5eb7.tar.bz2
misskey-d1785848289397b9e8242edd9bd87c5906fe5eb7.zip
Merge pull request #1116 from syuilo/vue-#972
Migrate to Vue
Diffstat (limited to 'src/api')
-rw-r--r--src/api/bot/core.ts4
-rw-r--r--src/api/endpoints.ts5
-rw-r--r--src/api/endpoints/i/update.ts8
-rw-r--r--src/api/endpoints/i/update_client_setting.ts43
-rw-r--r--src/api/private/signup.ts6
5 files changed, 54 insertions, 12 deletions
diff --git a/src/api/bot/core.ts b/src/api/bot/core.ts
index ddae6405f5..0a073a3127 100644
--- a/src/api/bot/core.ts
+++ b/src/api/bot/core.ts
@@ -305,7 +305,7 @@ class TlContext extends Context {
private async getTl() {
const tl = await require('../endpoints/posts/timeline')({
limit: 5,
- max_id: this.next ? this.next : undefined
+ until_id: this.next ? this.next : undefined
}, this.bot.user);
if (tl.length > 0) {
@@ -357,7 +357,7 @@ class NotificationsContext extends Context {
private async getNotifications() {
const notifications = await require('../endpoints/i/notifications')({
limit: 5,
- max_id: this.next ? this.next : undefined
+ until_id: this.next ? this.next : undefined
}, this.bot.user);
if (notifications.length > 0) {
diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts
index e846381578..ff214c3004 100644
--- a/src/api/endpoints.ts
+++ b/src/api/endpoints.ts
@@ -195,6 +195,11 @@ const endpoints: Endpoint[] = [
secure: true
},
{
+ name: 'i/update_client_setting',
+ withCredential: true,
+ secure: true
+ },
+ {
name: 'i/pin',
kind: 'account-write'
},
diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
index 7bbbf95900..43c5245044 100644
--- a/src/api/endpoints/i/update.ts
+++ b/src/api/endpoints/i/update.ts
@@ -46,19 +46,13 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
if (bannerIdErr) return rej('invalid banner_id param');
if (bannerId) user.banner_id = bannerId;
- // Get 'show_donation' parameter
- const [showDonation, showDonationErr] = $(params.show_donation).optional.boolean().$;
- if (showDonationErr) return rej('invalid show_donation param');
- if (showDonation) user.client_settings.show_donation = showDonation;
-
await User.update(user._id, {
$set: {
name: user.name,
description: user.description,
avatar_id: user.avatar_id,
banner_id: user.banner_id,
- profile: user.profile,
- 'client_settings.show_donation': user.client_settings.show_donation
+ profile: user.profile
}
});
diff --git a/src/api/endpoints/i/update_client_setting.ts b/src/api/endpoints/i/update_client_setting.ts
new file mode 100644
index 0000000000..b817ff354c
--- /dev/null
+++ b/src/api/endpoints/i/update_client_setting.ts
@@ -0,0 +1,43 @@
+/**
+ * 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[`client_settings.${name}`] = value;
+
+ await User.update(user._id, {
+ $set: x
+ });
+
+ // Serialize
+ user.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/private/signup.ts b/src/api/private/signup.ts
index 8efdb6db47..19e3314756 100644
--- a/src/api/private/signup.ts
+++ b/src/api/private/signup.ts
@@ -15,7 +15,7 @@ const home = {
'profile',
'calendar',
'activity',
- 'rss-reader',
+ 'rss',
'trends',
'photo-stream',
'version'
@@ -23,8 +23,8 @@ const home = {
right: [
'broadcast',
'notifications',
- 'user-recommendation',
- 'recommended-polls',
+ 'users',
+ 'polls',
'server',
'donation',
'nav',