summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-05-19 07:33:34 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-05-19 07:33:34 +0900
commite6eb1b2ae1c38b335ff4755d35a33a0ca4450454 (patch)
treef10a35f91071e36f787f77c242b127b7ad01c416 /src/models
parentFix (diff)
downloadsharkey-e6eb1b2ae1c38b335ff4755d35a33a0ca4450454.tar.gz
sharkey-e6eb1b2ae1c38b335ff4755d35a33a0ca4450454.tar.bz2
sharkey-e6eb1b2ae1c38b335ff4755d35a33a0ca4450454.zip
Clean up
Diffstat (limited to 'src/models')
-rw-r--r--src/models/channel-watching.ts13
-rw-r--r--src/models/channel.ts75
-rw-r--r--src/models/note.ts7
3 files changed, 0 insertions, 95 deletions
diff --git a/src/models/channel-watching.ts b/src/models/channel-watching.ts
deleted file mode 100644
index 44ca06883f..0000000000
--- a/src/models/channel-watching.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import * as mongo from 'mongodb';
-import db from '../db/mongodb';
-
-const ChannelWatching = db.get<IChannelWatching>('channelWatching');
-export default ChannelWatching;
-
-export interface IChannelWatching {
- _id: mongo.ObjectID;
- createdAt: Date;
- deletedAt: Date;
- channelId: mongo.ObjectID;
- userId: mongo.ObjectID;
-}
diff --git a/src/models/channel.ts b/src/models/channel.ts
deleted file mode 100644
index 67386ac072..0000000000
--- a/src/models/channel.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import * as mongo from 'mongodb';
-import deepcopy = require('deepcopy');
-import { IUser } from './user';
-import Watching from './channel-watching';
-import db from '../db/mongodb';
-
-const Channel = db.get<IChannel>('channels');
-export default Channel;
-
-export type IChannel = {
- _id: mongo.ObjectID;
- createdAt: Date;
- title: string;
- userId: mongo.ObjectID;
- index: number;
- watchingCount: number;
-};
-
-/**
- * Pack a channel for API response
- *
- * @param channel target
- * @param me? serializee
- * @return response
- */
-export const pack = (
- 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.userId;
-
- // Me
- const meId: mongo.ObjectID = me
- ? mongo.ObjectID.prototype.isPrototypeOf(me)
- ? me as mongo.ObjectID
- : typeof me === 'string'
- ? new mongo.ObjectID(me)
- : (me as IUser)._id
- : null;
-
- if (me) {
- //#region Watchしているかどうか
- const watch = await Watching.findOne({
- userId: meId,
- channelId: _channel.id,
- deletedAt: { $exists: false }
- });
-
- _channel.isWatching = watch !== null;
- //#endregion
- }
-
- resolve(_channel);
-});
diff --git a/src/models/note.ts b/src/models/note.ts
index f42bb2a49d..5070923363 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -4,7 +4,6 @@ import rap from '@prezzemolo/rap';
import db from '../db/mongodb';
import { IUser, pack as packUser } from './user';
import { pack as packApp } from './app';
-import { pack as packChannel } from './channel';
import PollVote, { deletePollVote } from './poll-vote';
import Reaction, { deleteNoteReaction } from './note-reaction';
import { pack as packFile } from './drive-file';
@@ -29,7 +28,6 @@ export function isValidCw(text: string): boolean {
export type INote = {
_id: mongo.ObjectID;
- channelId: mongo.ObjectID;
createdAt: Date;
deletedAt: Date;
mediaIds: mongo.ObjectID[];
@@ -258,11 +256,6 @@ export const pack = async (
_note.app = packApp(_note.appId);
}
- // Populate channel
- if (_note.channelId) {
- _note.channel = packChannel(_note.channelId);
- }
-
// Populate media
_note.media = hide ? [] : Promise.all(_note.mediaIds.map(fileId =>
packFile(fileId)