mirror of
https://github.com/paricafe/misskey.git
synced 2024-12-02 16:26:44 -06:00
31 lines
698 B
TypeScript
31 lines
698 B
TypeScript
/**
|
|
* Module dependencies
|
|
*/
|
|
import $ from 'cafy';
|
|
import { default as Channel, IChannel } from '../../models/channel';
|
|
import { pack } from '../../models/channel';
|
|
|
|
/**
|
|
* Show a channel
|
|
*
|
|
* @param {any} params
|
|
* @param {any} user
|
|
* @return {Promise<any>}
|
|
*/
|
|
module.exports = (params, user) => new Promise(async (res, rej) => {
|
|
// Get 'channel_id' parameter
|
|
const [channelId, channelIdErr] = $(params.channel_id).id().$;
|
|
if (channelIdErr) return rej('invalid channel_id param');
|
|
|
|
// Fetch channel
|
|
const channel: IChannel = await Channel.findOne({
|
|
_id: channelId
|
|
});
|
|
|
|
if (channel === null) {
|
|
return rej('channel not found');
|
|
}
|
|
|
|
// Serialize
|
|
res(await pack(channel, user));
|
|
});
|