summaryrefslogtreecommitdiff
path: root/src/server/api
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2018-09-04 19:24:23 +0900
committertamaina <tamaina@hotmail.co.jp>2018-09-04 19:24:23 +0900
commit15956839046937bc07f21afb29326ca43856be5c (patch)
tree13665b6d8cc5663a1ce3296e48da55ac1d337278 /src/server/api
parentUse string interpolation (diff)
parent:art: (diff)
downloadmisskey-15956839046937bc07f21afb29326ca43856be5c.tar.gz
misskey-15956839046937bc07f21afb29326ca43856be5c.tar.bz2
misskey-15956839046937bc07f21afb29326ca43856be5c.zip
merge upstream
Diffstat (limited to 'src/server/api')
-rw-r--r--src/server/api/endpoints/admin/update-meta.ts14
-rw-r--r--src/server/api/endpoints/messaging/messages/create.ts2
-rw-r--r--src/server/api/endpoints/meta.ts1
-rw-r--r--src/server/api/endpoints/users/lists/delete.ts43
-rw-r--r--src/server/api/endpoints/users/lists/update.ts56
-rw-r--r--src/server/api/stream/local-timeline.ts6
-rw-r--r--src/server/api/streaming.ts6
7 files changed, 121 insertions, 7 deletions
diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts
index 2c7929fabe..10ca15d329 100644
--- a/src/server/api/endpoints/admin/update-meta.ts
+++ b/src/server/api/endpoints/admin/update-meta.ts
@@ -11,11 +11,17 @@ export const meta = {
requireAdmin: true,
params: {
+ broadcasts: $.arr($.obj()).optional.nullable.note({
+ desc: {
+ 'ja-JP': 'ブロードキャスト'
+ }
+ }),
+
disableRegistration: $.bool.optional.nullable.note({
desc: {
'ja-JP': '招待制か否か'
}
- }),
+ })
}
};
@@ -25,7 +31,11 @@ export default (params: any) => new Promise(async (res, rej) => {
const set = {} as any;
- if (ps.disableRegistration === true || ps.disableRegistration === false) {
+ if (ps.broadcasts) {
+ set.broadcasts = ps.broadcasts;
+ }
+
+ if (typeof ps.disableRegistration === 'boolean') {
set.disableRegistration = ps.disableRegistration;
}
diff --git a/src/server/api/endpoints/messaging/messages/create.ts b/src/server/api/endpoints/messaging/messages/create.ts
index a6fabcfa45..9a49e09248 100644
--- a/src/server/api/endpoints/messaging/messages/create.ts
+++ b/src/server/api/endpoints/messaging/messages/create.ts
@@ -74,7 +74,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
createdAt: new Date(),
fileId: file ? file._id : undefined,
recipientId: recipient._id,
- text: text ? text : undefined,
+ text: text ? text.trim() : undefined,
userId: user._id,
isRead: false
});
diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts
index 2b39f26b8e..b0876eaafd 100644
--- a/src/server/api/endpoints/meta.ts
+++ b/src/server/api/endpoints/meta.ts
@@ -33,6 +33,7 @@ export default () => new Promise(async (res, rej) => {
},
broadcasts: meta.broadcasts,
disableRegistration: meta.disableRegistration,
+ driveCapacityPerLocalUserMb: config.localDriveCapacityMb,
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
swPublickey: config.sw ? config.sw.public_key : null
});
diff --git a/src/server/api/endpoints/users/lists/delete.ts b/src/server/api/endpoints/users/lists/delete.ts
new file mode 100644
index 0000000000..906534922e
--- /dev/null
+++ b/src/server/api/endpoints/users/lists/delete.ts
@@ -0,0 +1,43 @@
+import $ from 'cafy';
+import ID from '../../../../../misc/cafy-id';
+import UserList, { deleteUserList } from '../../../../../models/user-list';
+import { ILocalUser } from '../../../../../models/user';
+import getParams from '../../../get-params';
+
+export const meta = {
+ desc: {
+ 'ja-JP': '指定したユーザーリストを削除します。',
+ 'en-US': 'Delete a user list'
+ },
+
+ requireCredential: true,
+
+ kind: 'account-write',
+
+ params: {
+ listId: $.type(ID).note({
+ desc: {
+ 'ja-JP': '対象となるユーザーリストのID',
+ 'en-US': 'ID of target user list'
+ }
+ })
+ }
+};
+
+export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
+ const [ps, psErr] = getParams(meta, params);
+ if (psErr) return rej(psErr);
+
+ const userList = await UserList.findOne({
+ _id: ps.listId,
+ userId: user._id
+ });
+
+ if (userList == null) {
+ return rej('list not found');
+ }
+
+ deleteUserList(userList);
+
+ res();
+});
diff --git a/src/server/api/endpoints/users/lists/update.ts b/src/server/api/endpoints/users/lists/update.ts
new file mode 100644
index 0000000000..e6577eca4f
--- /dev/null
+++ b/src/server/api/endpoints/users/lists/update.ts
@@ -0,0 +1,56 @@
+import $ from 'cafy';
+import ID from '../../../../../misc/cafy-id';
+import UserList, { pack } from '../../../../../models/user-list';
+import { ILocalUser } from '../../../../../models/user';
+import getParams from '../../../get-params';
+
+export const meta = {
+ desc: {
+ 'ja-JP': '指定したユーザーリストを更新します。',
+ 'en-US': 'Update a user list'
+ },
+
+ requireCredential: true,
+
+ kind: 'account-write',
+
+ params: {
+ listId: $.type(ID).note({
+ desc: {
+ 'ja-JP': '対象となるユーザーリストのID',
+ 'en-US': 'ID of target user list'
+ }
+ }),
+ title: $.str.range(1, 100).note({
+ desc: {
+ 'ja-JP': 'このユーザーリストの名前',
+ 'en-US': 'name of this user list'
+ }
+ })
+ }
+};
+
+export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
+ const [ps, psErr] = getParams(meta, params);
+ if (psErr) throw psErr;
+
+ // Fetch the list
+ const userList = await UserList.findOne({
+ _id: ps.listId,
+ userId: user._id
+ });
+
+ if (userList == null) {
+ return rej('list not found');
+ }
+
+ // update
+ await UserList.update({ _id: userList._id }, {
+ $set: {
+ title: ps.title
+ }
+ });
+
+ // Response
+ res(await pack(userList._id));
+});
diff --git a/src/server/api/stream/local-timeline.ts b/src/server/api/stream/local-timeline.ts
index 82060a7aaa..25e0e00c9f 100644
--- a/src/server/api/stream/local-timeline.ts
+++ b/src/server/api/stream/local-timeline.ts
@@ -9,10 +9,10 @@ export default async function(
request: websocket.request,
connection: websocket.connection,
subscriber: Xev,
- user: IUser
+ user?: IUser
) {
- const mute = await Mute.find({ muterId: user._id });
- const mutedUserIds = mute.map(m => m.muteeId.toString());
+ const mute = user ? await Mute.find({ muterId: user._id }) : null;
+ const mutedUserIds = mute ? mute.map(m => m.muteeId.toString()) : [];
// Subscribe stream
subscriber.on('local-timeline', async note => {
diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts
index c8b2d4e0b9..e6094a40b2 100644
--- a/src/server/api/streaming.ts
+++ b/src/server/api/streaming.ts
@@ -52,6 +52,11 @@ module.exports = (server: http.Server) => {
return;
}
+ if (request.resourceURL.pathname === '/local-timeline') {
+ localTimelineStream(request, connection, ev, user);
+ return;
+ }
+
if (user == null) {
connection.send('authentication-failed');
connection.close();
@@ -60,7 +65,6 @@ module.exports = (server: http.Server) => {
const channel: any =
request.resourceURL.pathname === '/' ? homeStream :
- request.resourceURL.pathname === '/local-timeline' ? localTimelineStream :
request.resourceURL.pathname === '/hybrid-timeline' ? hybridTimelineStream :
request.resourceURL.pathname === '/global-timeline' ? globalTimelineStream :
request.resourceURL.pathname === '/user-list' ? userListStream :