RENAME: bbs -> channel
This commit is contained in:
parent
0e95cdb04c
commit
dc9fddf839
|
@ -352,10 +352,9 @@ desktop:
|
||||||
mk-repost-form-window:
|
mk-repost-form-window:
|
||||||
title: "Are you sure you want to repost this post?"
|
title: "Are you sure you want to repost this post?"
|
||||||
|
|
||||||
mk-bbs-page:
|
mk-channels-page:
|
||||||
title: "Misskey BBS"
|
new: "Create new channel"
|
||||||
new: "Create new thread"
|
channel-title: "Channel title"
|
||||||
thread-title: "Thread title"
|
|
||||||
|
|
||||||
mobile:
|
mobile:
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -352,10 +352,9 @@ desktop:
|
||||||
mk-repost-form-window:
|
mk-repost-form-window:
|
||||||
title: "この投稿をRepostしますか?"
|
title: "この投稿をRepostしますか?"
|
||||||
|
|
||||||
mk-bbs-page:
|
mk-channels-page:
|
||||||
title: "Misskey掲示板"
|
new: "チャンネルを作成"
|
||||||
new: "スレッドを作成"
|
channel-title: "チャンネルのタイトル"
|
||||||
thread-title: "スレッドのタイトル"
|
|
||||||
|
|
||||||
mobile:
|
mobile:
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
* Module dependencies
|
* Module dependencies
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Thread from '../../../models/bbs-thread';
|
import Channel from '../../../models/channel';
|
||||||
import serialize from '../../../serializers/bbs-thread';
|
import serialize from '../../../serializers/channel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a thread
|
* Create a channel
|
||||||
*
|
*
|
||||||
* @param {any} params
|
* @param {any} params
|
||||||
* @param {any} user
|
* @param {any} user
|
||||||
|
@ -17,13 +17,13 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
const [title, titleErr] = $(params.title).string().range(1, 100).$;
|
const [title, titleErr] = $(params.title).string().range(1, 100).$;
|
||||||
if (titleErr) return rej('invalid title param');
|
if (titleErr) return rej('invalid title param');
|
||||||
|
|
||||||
// Create a thread
|
// Create a channel
|
||||||
const thread = await Thread.insert({
|
const channel = await Channel.insert({
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
user_id: user._id,
|
user_id: user._id,
|
||||||
title: title
|
title: title
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(await serialize(thread));
|
res(await serialize(channel));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import db from '../../db/mongodb';
|
import db from '../../db/mongodb';
|
||||||
|
|
||||||
const collection = db.get('bbs_threads');
|
const collection = db.get('channels');
|
||||||
|
|
||||||
export default collection as any; // fuck type definition
|
export default collection as any; // fuck type definition
|
||||||
|
|
||||||
export type IBbsThread = {
|
export type IChannel = {
|
||||||
_id: mongo.ObjectID;
|
_id: mongo.ObjectID;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
title: string;
|
title: string;
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* Module dependencies
|
|
||||||
*/
|
|
||||||
import * as mongo from 'mongodb';
|
|
||||||
import deepcopy = require('deepcopy');
|
|
||||||
import { IUser } from '../models/user';
|
|
||||||
import { default as Thread, IBbsThread } from '../models/bbs-thread';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialize a thread
|
|
||||||
*
|
|
||||||
* @param thread target
|
|
||||||
* @param me? serializee
|
|
||||||
* @return response
|
|
||||||
*/
|
|
||||||
export default (
|
|
||||||
thread: string | mongo.ObjectID | IBbsThread,
|
|
||||||
me?: string | mongo.ObjectID | IUser
|
|
||||||
) => new Promise<any>(async (resolve, reject) => {
|
|
||||||
|
|
||||||
let _thread: any;
|
|
||||||
|
|
||||||
// Populate the thread if 'thread' is ID
|
|
||||||
if (mongo.ObjectID.prototype.isPrototypeOf(thread)) {
|
|
||||||
_thread = await Thread.findOne({
|
|
||||||
_id: thread
|
|
||||||
});
|
|
||||||
} else if (typeof thread === 'string') {
|
|
||||||
_thread = await Thread.findOne({
|
|
||||||
_id: new mongo.ObjectID(thread)
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
_thread = deepcopy(thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename _id to id
|
|
||||||
_thread.id = _thread._id;
|
|
||||||
delete _thread._id;
|
|
||||||
|
|
||||||
// Remove needless properties
|
|
||||||
delete _thread.user_id;
|
|
||||||
|
|
||||||
resolve(_thread);
|
|
||||||
});
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* Module dependencies
|
||||||
|
*/
|
||||||
|
import * as mongo from 'mongodb';
|
||||||
|
import deepcopy = require('deepcopy');
|
||||||
|
import { IUser } from '../models/user';
|
||||||
|
import { default as Channel, IChannel } from '../models/channel';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize a channel
|
||||||
|
*
|
||||||
|
* @param channel target
|
||||||
|
* @param me? serializee
|
||||||
|
* @return response
|
||||||
|
*/
|
||||||
|
export default (
|
||||||
|
channel: string | mongo.ObjectID | IChannel,
|
||||||
|
me?: string | mongo.ObjectID | IUser
|
||||||
|
) => new Promise<any>(async (resolve, reject) => {
|
||||||
|
|
||||||
|
let _channel: any;
|
||||||
|
|
||||||
|
// Populate the channel if 'channel' is ID
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(channel)) {
|
||||||
|
_channel = await Channel.findOne({
|
||||||
|
_id: channel
|
||||||
|
});
|
||||||
|
} else if (typeof channel === 'string') {
|
||||||
|
_channel = await Channel.findOne({
|
||||||
|
_id: new mongo.ObjectID(channel)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_channel = deepcopy(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename _id to id
|
||||||
|
_channel.id = _channel._id;
|
||||||
|
delete _channel._id;
|
||||||
|
|
||||||
|
// Remove needless properties
|
||||||
|
delete _channel.user_id;
|
||||||
|
|
||||||
|
resolve(_channel);
|
||||||
|
});
|
|
@ -61,7 +61,7 @@ require('./pages/user.tag');
|
||||||
require('./pages/post.tag');
|
require('./pages/post.tag');
|
||||||
require('./pages/search.tag');
|
require('./pages/search.tag');
|
||||||
require('./pages/not-found.tag');
|
require('./pages/not-found.tag');
|
||||||
require('./pages/bbs.tag');
|
require('./pages/channels.tag');
|
||||||
require('./autocomplete-suggestion.tag');
|
require('./autocomplete-suggestion.tag');
|
||||||
require('./progress-dialog.tag');
|
require('./progress-dialog.tag');
|
||||||
require('./user-preview.tag');
|
require('./user-preview.tag');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<mk-bbs-page>
|
<mk-channels-page>
|
||||||
<mk-ui ref="ui">
|
<mk-ui ref="ui">
|
||||||
<main>
|
<main>
|
||||||
<h1>%i18n:desktop.tags.mk-bbs-page.title%</h1>
|
<h1>%i18n:desktop.tags.mk-bbs-page.title%</h1>
|
||||||
|
@ -18,13 +18,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
this.new = () => {
|
this.new = () => {
|
||||||
const title = window.prompt('%i18n:desktop.tags.mk-bbs-page.thread-title%');
|
const title = window.prompt('%i18n:desktop.tags.mk-bbs-page.channel-title%');
|
||||||
|
|
||||||
this.api('bbs/threads/create', {
|
this.api('bbs/channels/create', {
|
||||||
title: title
|
title: title
|
||||||
}).then(thread => {
|
}).then(channel => {
|
||||||
location.href = '/bbs/' + thread.id;
|
location.href = '/bbs/' + channel.id;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
</mk-bbs-page>
|
</mk-channels-page>
|
Loading…
Reference in New Issue