整理した
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import * as express from 'express';
|
||||
import App from './models/app';
|
||||
import { default as User, IUser } from './models/user';
|
||||
import AccessToken from './models/access-token';
|
||||
import App from '../../models/app';
|
||||
import { default as User, IUser } from '../../models/user';
|
||||
import AccessToken from '../../models/access-token';
|
||||
import isNativeToken from './common/is-native-token';
|
||||
|
||||
export interface IAuthContext {
|
||||
|
@ -1,12 +1,12 @@
|
||||
import * as EventEmitter from 'events';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
|
||||
import User, { ILocalAccount, IUser, init as initUser } from '../models/user';
|
||||
import User, { ILocalAccount, IUser, init as initUser } from '../../../models/user';
|
||||
|
||||
import getPostSummary from '../../common/get-post-summary';
|
||||
import getUserSummary from '../../common/user/get-summary';
|
||||
import parseAcct from '../../common/user/parse-acct';
|
||||
import getNotificationSummary from '../../common/get-notification-summary';
|
||||
import getPostSummary from '../../../common/get-post-summary';
|
||||
import getUserSummary from '../../../common/user/get-summary';
|
||||
import parseAcct from '../../../common/user/parse-acct';
|
||||
import getNotificationSummary from '../../../common/get-notification-summary';
|
||||
|
||||
const hmm = [
|
||||
'?',
|
||||
|
@ -2,14 +2,14 @@ import * as EventEmitter from 'events';
|
||||
import * as express from 'express';
|
||||
import * as request from 'request';
|
||||
import * as crypto from 'crypto';
|
||||
import User from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
import config from '../../../../conf';
|
||||
import BotCore from '../core';
|
||||
import _redis from '../../../../db/redis';
|
||||
import prominence = require('prominence');
|
||||
import getAcct from '../../../common/user/get-acct';
|
||||
import parseAcct from '../../../common/user/parse-acct';
|
||||
import getPostSummary from '../../../common/get-post-summary';
|
||||
import getAcct from '../../../../common/user/get-acct';
|
||||
import parseAcct from '../../../../common/user/parse-acct';
|
||||
import getPostSummary from '../../../../common/get-post-summary';
|
||||
|
||||
const redis = prominence(_redis);
|
||||
|
||||
|
@ -10,11 +10,11 @@ import * as debug from 'debug';
|
||||
import fileType = require('file-type');
|
||||
import prominence = require('prominence');
|
||||
|
||||
import DriveFile, { getGridFSBucket } from '../../models/drive-file';
|
||||
import DriveFolder from '../../models/drive-folder';
|
||||
import { pack } from '../../models/drive-file';
|
||||
import DriveFile, { getGridFSBucket } from '../../../../models/drive-file';
|
||||
import DriveFolder from '../../../../models/drive-folder';
|
||||
import { pack } from '../../../../models/drive-file';
|
||||
import event, { publishDriveStream } from '../../event';
|
||||
import getAcct from '../../../common/user/get-acct';
|
||||
import getAcct from '../../../../common/user/get-acct';
|
||||
import config from '../../../../conf';
|
||||
|
||||
const gm = _gm.subClass({
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as URL from 'url';
|
||||
import { IDriveFile, validateFileName } from '../../models/drive-file';
|
||||
import { IDriveFile, validateFileName } from '../../../../models/drive-file';
|
||||
import create from './add-file';
|
||||
import * as debug from 'debug';
|
||||
import * as tmp from 'tmp';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as mongodb from 'mongodb';
|
||||
import Following from '../models/following';
|
||||
import Following from '../../../models/following';
|
||||
|
||||
export default async (me: mongodb.ObjectID, includeMe: boolean = true) => {
|
||||
// Fetch relation to other users who the I follows
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import Notification from '../models/notification';
|
||||
import Mute from '../models/mute';
|
||||
import Notification from '../../../models/notification';
|
||||
import Mute from '../../../models/mute';
|
||||
import event from '../event';
|
||||
import { pack } from '../models/notification';
|
||||
import { pack } from '../../../models/notification';
|
||||
|
||||
export default (
|
||||
notifiee: mongo.ObjectID,
|
||||
|
@ -1,6 +1,6 @@
|
||||
const push = require('web-push');
|
||||
import * as mongo from 'mongodb';
|
||||
import Subscription from '../models/sw-subscription';
|
||||
import Subscription from '../../../models/sw-subscription';
|
||||
import config from '../../../conf';
|
||||
|
||||
if (config.sw) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import Message from '../models/messaging-message';
|
||||
import { IMessagingMessage as IMessage } from '../models/messaging-message';
|
||||
import Message from '../../../models/messaging-message';
|
||||
import { IMessagingMessage as IMessage } from '../../../models/messaging-message';
|
||||
import publishUserStream from '../event';
|
||||
import { publishMessagingStream } from '../event';
|
||||
import { publishMessagingIndexStream } from '../event';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import { default as Notification, INotification } from '../models/notification';
|
||||
import { default as Notification, INotification } from '../../../models/notification';
|
||||
import publishUserStream from '../event';
|
||||
|
||||
/**
|
||||
|
@ -1,334 +0,0 @@
|
||||
function escape(text) {
|
||||
return text
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<');
|
||||
}
|
||||
|
||||
// 文字数が多い順にソートします
|
||||
// そうしないと、「function」という文字列が与えられたときに「func」が先にマッチしてしまう可能性があるためです
|
||||
const _keywords = [
|
||||
'true',
|
||||
'false',
|
||||
'null',
|
||||
'nil',
|
||||
'undefined',
|
||||
'void',
|
||||
'var',
|
||||
'const',
|
||||
'let',
|
||||
'mut',
|
||||
'dim',
|
||||
'if',
|
||||
'then',
|
||||
'else',
|
||||
'switch',
|
||||
'match',
|
||||
'case',
|
||||
'default',
|
||||
'for',
|
||||
'each',
|
||||
'in',
|
||||
'while',
|
||||
'loop',
|
||||
'continue',
|
||||
'break',
|
||||
'do',
|
||||
'goto',
|
||||
'next',
|
||||
'end',
|
||||
'sub',
|
||||
'throw',
|
||||
'try',
|
||||
'catch',
|
||||
'finally',
|
||||
'enum',
|
||||
'delegate',
|
||||
'function',
|
||||
'func',
|
||||
'fun',
|
||||
'fn',
|
||||
'return',
|
||||
'yield',
|
||||
'async',
|
||||
'await',
|
||||
'require',
|
||||
'include',
|
||||
'import',
|
||||
'imports',
|
||||
'export',
|
||||
'exports',
|
||||
'from',
|
||||
'as',
|
||||
'using',
|
||||
'use',
|
||||
'internal',
|
||||
'module',
|
||||
'namespace',
|
||||
'where',
|
||||
'select',
|
||||
'struct',
|
||||
'union',
|
||||
'new',
|
||||
'delete',
|
||||
'this',
|
||||
'super',
|
||||
'base',
|
||||
'class',
|
||||
'interface',
|
||||
'abstract',
|
||||
'static',
|
||||
'public',
|
||||
'private',
|
||||
'protected',
|
||||
'virtual',
|
||||
'partial',
|
||||
'override',
|
||||
'extends',
|
||||
'implements',
|
||||
'constructor'
|
||||
];
|
||||
|
||||
const keywords = _keywords
|
||||
.concat(_keywords.map(k => k[0].toUpperCase() + k.substr(1)))
|
||||
.concat(_keywords.map(k => k.toUpperCase()))
|
||||
.sort((a, b) => b.length - a.length);
|
||||
|
||||
const symbols = [
|
||||
'=',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'~',
|
||||
'^',
|
||||
'&',
|
||||
'|',
|
||||
'>',
|
||||
'<',
|
||||
'!',
|
||||
'?'
|
||||
];
|
||||
|
||||
const elements = [
|
||||
// comment
|
||||
code => {
|
||||
if (code.substr(0, 2) != '//') return null;
|
||||
const match = code.match(/^\/\/(.+?)(\n|$)/);
|
||||
if (!match) return null;
|
||||
const comment = match[0];
|
||||
return {
|
||||
html: `<span class="comment">${escape(comment)}</span>`,
|
||||
next: comment.length
|
||||
};
|
||||
},
|
||||
|
||||
// block comment
|
||||
code => {
|
||||
const match = code.match(/^\/\*([\s\S]+?)\*\//);
|
||||
if (!match) return null;
|
||||
return {
|
||||
html: `<span class="comment">${escape(match[0])}</span>`,
|
||||
next: match[0].length
|
||||
};
|
||||
},
|
||||
|
||||
// string
|
||||
code => {
|
||||
if (!/^['"`]/.test(code)) return null;
|
||||
const begin = code[0];
|
||||
let str = begin;
|
||||
let thisIsNotAString = false;
|
||||
for (let i = 1; i < code.length; i++) {
|
||||
const char = code[i];
|
||||
if (char == '\\') {
|
||||
str += char;
|
||||
str += code[i + 1] || '';
|
||||
i++;
|
||||
continue;
|
||||
} else if (char == begin) {
|
||||
str += char;
|
||||
break;
|
||||
} else if (char == '\n' || i == (code.length - 1)) {
|
||||
thisIsNotAString = true;
|
||||
break;
|
||||
} else {
|
||||
str += char;
|
||||
}
|
||||
}
|
||||
if (thisIsNotAString) {
|
||||
return null;
|
||||
} else {
|
||||
return {
|
||||
html: `<span class="string">${escape(str)}</span>`,
|
||||
next: str.length
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// regexp
|
||||
code => {
|
||||
if (code[0] != '/') return null;
|
||||
let regexp = '';
|
||||
let thisIsNotARegexp = false;
|
||||
for (let i = 1; i < code.length; i++) {
|
||||
const char = code[i];
|
||||
if (char == '\\') {
|
||||
regexp += char;
|
||||
regexp += code[i + 1] || '';
|
||||
i++;
|
||||
continue;
|
||||
} else if (char == '/') {
|
||||
break;
|
||||
} else if (char == '\n' || i == (code.length - 1)) {
|
||||
thisIsNotARegexp = true;
|
||||
break;
|
||||
} else {
|
||||
regexp += char;
|
||||
}
|
||||
}
|
||||
|
||||
if (thisIsNotARegexp) return null;
|
||||
if (regexp == '') return null;
|
||||
if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null;
|
||||
|
||||
return {
|
||||
html: `<span class="regexp">/${escape(regexp)}/</span>`,
|
||||
next: regexp.length + 2
|
||||
};
|
||||
},
|
||||
|
||||
// label
|
||||
code => {
|
||||
if (code[0] != '@') return null;
|
||||
const match = code.match(/^@([a-zA-Z_-]+?)\n/);
|
||||
if (!match) return null;
|
||||
const label = match[0];
|
||||
return {
|
||||
html: `<span class="label">${label}</span>`,
|
||||
next: label.length
|
||||
};
|
||||
},
|
||||
|
||||
// number
|
||||
(code, i, source) => {
|
||||
const prev = source[i - 1];
|
||||
if (prev && /[a-zA-Z]/.test(prev)) return null;
|
||||
if (!/^[\-\+]?[0-9\.]+/.test(code)) return null;
|
||||
const match = code.match(/^[\-\+]?[0-9\.]+/)[0];
|
||||
if (match) {
|
||||
return {
|
||||
html: `<span class="number">${match}</span>`,
|
||||
next: match.length
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
// nan
|
||||
(code, i, source) => {
|
||||
const prev = source[i - 1];
|
||||
if (prev && /[a-zA-Z]/.test(prev)) return null;
|
||||
if (code.substr(0, 3) == 'NaN') {
|
||||
return {
|
||||
html: `<span class="nan">NaN</span>`,
|
||||
next: 3
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
// method
|
||||
code => {
|
||||
const match = code.match(/^([a-zA-Z_-]+?)\(/);
|
||||
if (!match) return null;
|
||||
|
||||
if (match[1] == '-') return null;
|
||||
|
||||
return {
|
||||
html: `<span class="method">${match[1]}</span>`,
|
||||
next: match[1].length
|
||||
};
|
||||
},
|
||||
|
||||
// property
|
||||
(code, i, source) => {
|
||||
const prev = source[i - 1];
|
||||
if (prev != '.') return null;
|
||||
|
||||
const match = code.match(/^[a-zA-Z0-9_-]+/);
|
||||
if (!match) return null;
|
||||
|
||||
return {
|
||||
html: `<span class="property">${match[0]}</span>`,
|
||||
next: match[0].length
|
||||
};
|
||||
},
|
||||
|
||||
// keyword
|
||||
(code, i, source) => {
|
||||
const prev = source[i - 1];
|
||||
if (prev && /[a-zA-Z]/.test(prev)) return null;
|
||||
|
||||
const match = keywords.filter(k => code.substr(0, k.length) == k)[0];
|
||||
if (match) {
|
||||
if (/^[a-zA-Z]/.test(code.substr(match.length))) return null;
|
||||
return {
|
||||
html: `<span class="keyword ${match}">${match}</span>`,
|
||||
next: match.length
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
// symbol
|
||||
code => {
|
||||
const match = symbols.filter(s => code[0] == s)[0];
|
||||
if (match) {
|
||||
return {
|
||||
html: `<span class="symbol">${match}</span>`,
|
||||
next: 1
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// specify lang is todo
|
||||
export default (source: string, lang?: string) => {
|
||||
let code = source;
|
||||
let html = '';
|
||||
|
||||
let i = 0;
|
||||
|
||||
function push(token) {
|
||||
html += token.html;
|
||||
code = code.substr(token.next);
|
||||
i += token.next;
|
||||
}
|
||||
|
||||
while (code != '') {
|
||||
const parsed = elements.some(el => {
|
||||
const e = el(code, i, source);
|
||||
if (e) {
|
||||
push(e);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!parsed) {
|
||||
push({
|
||||
html: escape(code[0]),
|
||||
next: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Bold
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^\*\*(.+?)\*\*/);
|
||||
if (!match) return null;
|
||||
const bold = match[0];
|
||||
return {
|
||||
type: 'bold',
|
||||
content: bold,
|
||||
bold: bold.substr(2, bold.length - 4)
|
||||
};
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Code (block)
|
||||
*/
|
||||
|
||||
import genHtml from '../core/syntax-highlighter';
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^```([\s\S]+?)```/);
|
||||
if (!match) return null;
|
||||
const code = match[0];
|
||||
return {
|
||||
type: 'code',
|
||||
content: code,
|
||||
code: code.substr(3, code.length - 6).trim(),
|
||||
html: genHtml(code.substr(3, code.length - 6).trim())
|
||||
};
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Emoji
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^:[a-zA-Z0-9+-_]+:/);
|
||||
if (!match) return null;
|
||||
const emoji = match[0];
|
||||
return {
|
||||
type: 'emoji',
|
||||
content: emoji,
|
||||
emoji: emoji.substr(1, emoji.length - 2)
|
||||
};
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Hashtag
|
||||
*/
|
||||
|
||||
module.exports = (text, i) => {
|
||||
if (!(/^\s#[^\s]+/.test(text) || (i == 0 && /^#[^\s]+/.test(text)))) return null;
|
||||
const isHead = text[0] == '#';
|
||||
const hashtag = text.match(/^\s?#[^\s]+/)[0];
|
||||
const res: any[] = !isHead ? [{
|
||||
type: 'text',
|
||||
content: text[0]
|
||||
}] : [];
|
||||
res.push({
|
||||
type: 'hashtag',
|
||||
content: isHead ? hashtag : hashtag.substr(1),
|
||||
hashtag: isHead ? hashtag.substr(1) : hashtag.substr(2)
|
||||
});
|
||||
return res;
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Code (inline)
|
||||
*/
|
||||
|
||||
import genHtml from '../core/syntax-highlighter';
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^`(.+?)`/);
|
||||
if (!match) return null;
|
||||
const code = match[0];
|
||||
return {
|
||||
type: 'inline-code',
|
||||
content: code,
|
||||
code: code.substr(1, code.length - 2).trim(),
|
||||
html: genHtml(code.substr(1, code.length - 2).trim())
|
||||
};
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Link
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^\??\[([^\[\]]+?)\]\((https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+?)\)/);
|
||||
if (!match) return null;
|
||||
const silent = text[0] == '?';
|
||||
const link = match[0];
|
||||
const title = match[1];
|
||||
const url = match[2];
|
||||
return {
|
||||
type: 'link',
|
||||
content: link,
|
||||
title: title,
|
||||
url: url,
|
||||
silent: silent
|
||||
};
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Mention
|
||||
*/
|
||||
import parseAcct from '../../../../common/user/parse-acct';
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^(?:@[a-zA-Z0-9\-]+){1,2}/);
|
||||
if (!match) return null;
|
||||
const mention = match[0];
|
||||
const { username, host } = parseAcct(mention.substr(1));
|
||||
return {
|
||||
type: 'mention',
|
||||
content: mention,
|
||||
username,
|
||||
host
|
||||
};
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Quoted text
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^"([\s\S]+?)\n"/);
|
||||
if (!match) return null;
|
||||
const quote = match[0];
|
||||
return {
|
||||
type: 'quote',
|
||||
content: quote,
|
||||
quote: quote.substr(1, quote.length - 2).trim(),
|
||||
};
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
|
||||
if (!match) return null;
|
||||
const url = match[0];
|
||||
return {
|
||||
type: 'url',
|
||||
content: url,
|
||||
url: url
|
||||
};
|
||||
};
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Misskey Text Analyzer
|
||||
*/
|
||||
|
||||
const elements = [
|
||||
require('./elements/bold'),
|
||||
require('./elements/url'),
|
||||
require('./elements/link'),
|
||||
require('./elements/mention'),
|
||||
require('./elements/hashtag'),
|
||||
require('./elements/code'),
|
||||
require('./elements/inline-code'),
|
||||
require('./elements/quote'),
|
||||
require('./elements/emoji')
|
||||
];
|
||||
|
||||
export default (source: string) => {
|
||||
|
||||
if (source == '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tokens = [];
|
||||
|
||||
function push(token) {
|
||||
if (token != null) {
|
||||
tokens.push(token);
|
||||
source = source.substr(token.content.length);
|
||||
}
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
|
||||
// パース
|
||||
while (source != '') {
|
||||
const parsed = elements.some(el => {
|
||||
let _tokens = el(source, i);
|
||||
if (_tokens) {
|
||||
if (!Array.isArray(_tokens)) {
|
||||
_tokens = [_tokens];
|
||||
}
|
||||
_tokens.forEach(push);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!parsed) {
|
||||
push({
|
||||
type: 'text',
|
||||
content: source[0]
|
||||
});
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
// テキストを纏める
|
||||
tokens[0] = [tokens[0]];
|
||||
return tokens.reduce((a, b) => {
|
||||
if (a[a.length - 1].type == 'text' && b.type == 'text') {
|
||||
const tail = a.pop();
|
||||
return a.concat({
|
||||
type: 'text',
|
||||
content: tail.content + b.content
|
||||
});
|
||||
} else {
|
||||
return a.concat(b);
|
||||
}
|
||||
});
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
import * as mongodb from 'mongodb';
|
||||
import Watching from '../models/post-watching';
|
||||
import Watching from '../../../models/post-watching';
|
||||
|
||||
export default async (me: mongodb.ObjectID, post: object) => {
|
||||
// 自分の投稿はwatchできない
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../models/post';
|
||||
import Post from '../../../../models/post';
|
||||
|
||||
/**
|
||||
* Aggregate posts
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../../models/post';
|
||||
import Reaction from '../../../models/post-reaction';
|
||||
import Post from '../../../../../models/post';
|
||||
import Reaction from '../../../../../models/post-reaction';
|
||||
|
||||
/**
|
||||
* Aggregate reaction of a post
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../../models/post';
|
||||
import Reaction from '../../../models/post-reaction';
|
||||
import Post from '../../../../../models/post';
|
||||
import Reaction from '../../../../../models/post-reaction';
|
||||
|
||||
/**
|
||||
* Aggregate reactions of a post
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../../models/post';
|
||||
import Post from '../../../../../models/post';
|
||||
|
||||
/**
|
||||
* Aggregate reply of a post
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../../models/post';
|
||||
import Post from '../../../../../models/post';
|
||||
|
||||
/**
|
||||
* Aggregate repost of a post
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Aggregate users
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../../models/user';
|
||||
import Post from '../../../models/post';
|
||||
import User from '../../../../../models/user';
|
||||
import Post from '../../../../../models/post';
|
||||
|
||||
// TODO: likeやfollowも集計
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../../models/user';
|
||||
import Following from '../../../models/following';
|
||||
import User from '../../../../../models/user';
|
||||
import Following from '../../../../../models/following';
|
||||
|
||||
/**
|
||||
* Aggregate followers of a user
|
||||
@ -39,11 +39,12 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||
{ deletedAt: { $gt: startTime } }
|
||||
]
|
||||
}, {
|
||||
_id: false,
|
||||
followerId: false,
|
||||
followeeId: false
|
||||
}, {
|
||||
sort: { createdAt: -1 }
|
||||
sort: { createdAt: -1 },
|
||||
fields: {
|
||||
_id: false,
|
||||
followerId: false,
|
||||
followeeId: false
|
||||
}
|
||||
});
|
||||
|
||||
const graph = [];
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../../models/user';
|
||||
import Following from '../../../models/following';
|
||||
import User from '../../../../../models/user';
|
||||
import Following from '../../../../../models/following';
|
||||
|
||||
/**
|
||||
* Aggregate following of a user
|
||||
@ -39,11 +39,12 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||
{ deletedAt: { $gt: startTime } }
|
||||
]
|
||||
}, {
|
||||
_id: false,
|
||||
followerId: false,
|
||||
followeeId: false
|
||||
}, {
|
||||
sort: { createdAt: -1 }
|
||||
sort: { createdAt: -1 },
|
||||
fields: {
|
||||
_id: false,
|
||||
followerId: false,
|
||||
followeeId: false
|
||||
}
|
||||
});
|
||||
|
||||
const graph = [];
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../../models/user';
|
||||
import Post from '../../../models/post';
|
||||
import User from '../../../../../models/user';
|
||||
import Post from '../../../../../models/post';
|
||||
|
||||
/**
|
||||
* Aggregate post of a user
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../../models/user';
|
||||
import Reaction from '../../../models/post-reaction';
|
||||
import User from '../../../../../models/user';
|
||||
import Reaction from '../../../../../models/post-reaction';
|
||||
|
||||
/**
|
||||
* Aggregate reaction of a user
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import rndstr from 'rndstr';
|
||||
import $ from 'cafy';
|
||||
import App, { isValidNameId, pack } from '../../models/app';
|
||||
import App, { isValidNameId, pack } from '../../../../models/app';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import App from '../../../models/app';
|
||||
import { isValidNameId } from '../../../models/app';
|
||||
import App from '../../../../../models/app';
|
||||
import { isValidNameId } from '../../../../../models/app';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import App, { pack } from '../../models/app';
|
||||
import App, { pack } from '../../../../models/app';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
@ -4,9 +4,9 @@
|
||||
import rndstr from 'rndstr';
|
||||
const crypto = require('crypto');
|
||||
import $ from 'cafy';
|
||||
import App from '../../models/app';
|
||||
import AuthSess from '../../models/auth-session';
|
||||
import AccessToken from '../../models/access-token';
|
||||
import App from '../../../../models/app';
|
||||
import AuthSess from '../../../../models/auth-session';
|
||||
import AccessToken from '../../../../models/access-token';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
@ -3,8 +3,8 @@
|
||||
*/
|
||||
import * as uuid from 'uuid';
|
||||
import $ from 'cafy';
|
||||
import App from '../../../models/app';
|
||||
import AuthSess from '../../../models/auth-session';
|
||||
import App from '../../../../../models/app';
|
||||
import AuthSess from '../../../../../models/auth-session';
|
||||
import config from '../../../../../conf';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import AuthSess, { pack } from '../../../models/auth-session';
|
||||
import AuthSess, { pack } from '../../../../../models/auth-session';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
@ -2,10 +2,10 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import App from '../../../models/app';
|
||||
import AuthSess from '../../../models/auth-session';
|
||||
import AccessToken from '../../../models/access-token';
|
||||
import { pack } from '../../../models/user';
|
||||
import App from '../../../../../models/app';
|
||||
import AuthSess from '../../../../../models/auth-session';
|
||||
import AccessToken from '../../../../../models/access-token';
|
||||
import { pack } from '../../../../../models/user';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Channel, { pack } from '../models/channel';
|
||||
import Channel, { pack } from '../../../models/channel';
|
||||
|
||||
/**
|
||||
* Get all channels
|
||||
|
@ -2,9 +2,9 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Channel from '../../models/channel';
|
||||
import Watching from '../../models/channel-watching';
|
||||
import { pack } from '../../models/channel';
|
||||
import Channel from '../../../../models/channel';
|
||||
import Watching from '../../../../models/channel-watching';
|
||||
import { pack } from '../../../../models/channel';
|
||||
|
||||
/**
|
||||
* Create a channel
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import { default as Channel, IChannel } from '../../models/channel';
|
||||
import Post, { pack } from '../../models/post';
|
||||
import { default as Channel, IChannel } from '../../../../models/channel';
|
||||
import Post, { pack } from '../../../../models/post';
|
||||
|
||||
/**
|
||||
* Show a posts of a channel
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Channel, { IChannel, pack } from '../../models/channel';
|
||||
import Channel, { IChannel, pack } from '../../../../models/channel';
|
||||
|
||||
/**
|
||||
* Show a channel
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Channel from '../../models/channel';
|
||||
import Watching from '../../models/channel-watching';
|
||||
import Channel from '../../../../models/channel';
|
||||
import Watching from '../../../../models/channel-watching';
|
||||
|
||||
/**
|
||||
* Unwatch a channel
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Channel from '../../models/channel';
|
||||
import Watching from '../../models/channel-watching';
|
||||
import Channel from '../../../../models/channel';
|
||||
import Watching from '../../../../models/channel-watching';
|
||||
|
||||
/**
|
||||
* Watch a channel
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import DriveFile from '../models/drive-file';
|
||||
import DriveFile from '../../../models/drive-file';
|
||||
|
||||
/**
|
||||
* Get drive information
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFile, { pack } from '../../models/drive-file';
|
||||
import DriveFile, { pack } from '../../../../models/drive-file';
|
||||
|
||||
/**
|
||||
* Get drive files
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import { validateFileName, pack } from '../../../models/drive-file';
|
||||
import { validateFileName, pack } from '../../../../../models/drive-file';
|
||||
import create from '../../../common/drive/add-file';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFile, { pack } from '../../../models/drive-file';
|
||||
import DriveFile, { pack } from '../../../../../models/drive-file';
|
||||
|
||||
/**
|
||||
* Find a file(s)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFile, { pack } from '../../../models/drive-file';
|
||||
import DriveFile, { pack } from '../../../../../models/drive-file';
|
||||
|
||||
/**
|
||||
* Show a file
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder from '../../../models/drive-folder';
|
||||
import DriveFile, { validateFileName, pack } from '../../../models/drive-file';
|
||||
import DriveFolder from '../../../../../models/drive-folder';
|
||||
import DriveFile, { validateFileName, pack } from '../../../../../models/drive-file';
|
||||
import { publishDriveStream } from '../../../event';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import { pack } from '../../../models/drive-file';
|
||||
import { pack } from '../../../../../models/drive-file';
|
||||
import uploadFromUrl from '../../../common/drive/upload_from_url';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder, { pack } from '../../models/drive-folder';
|
||||
import DriveFolder, { pack } from '../../../../models/drive-folder';
|
||||
|
||||
/**
|
||||
* Get drive folders
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder, { isValidFolderName, pack } from '../../../models/drive-folder';
|
||||
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
|
||||
import { publishDriveStream } from '../../../event';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder, { pack } from '../../../models/drive-folder';
|
||||
import DriveFolder, { pack } from '../../../../../models/drive-folder';
|
||||
|
||||
/**
|
||||
* Find a folder(s)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder, { pack } from '../../../models/drive-folder';
|
||||
import DriveFolder, { pack } from '../../../../../models/drive-folder';
|
||||
|
||||
/**
|
||||
* Show a folder
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder, { isValidFolderName, pack } from '../../../models/drive-folder';
|
||||
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
|
||||
import { publishDriveStream } from '../../../event';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFile, { pack } from '../../models/drive-file';
|
||||
import DriveFile, { pack } from '../../../../models/drive-file';
|
||||
|
||||
/**
|
||||
* Get drive stream
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User, { pack as packUser } from '../../models/user';
|
||||
import Following from '../../models/following';
|
||||
import User, { pack as packUser } from '../../../../models/user';
|
||||
import Following from '../../../../models/following';
|
||||
import notify from '../../common/notify';
|
||||
import event from '../../event';
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User, { pack as packUser } from '../../models/user';
|
||||
import Following from '../../models/following';
|
||||
import User, { pack as packUser } from '../../../../models/user';
|
||||
import Following from '../../../../models/following';
|
||||
import event from '../../event';
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import User, { pack } from '../models/user';
|
||||
import User, { pack } from '../../../models/user';
|
||||
|
||||
/**
|
||||
* Show myself
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import * as speakeasy from 'speakeasy';
|
||||
import User from '../../../models/user';
|
||||
import User from '../../../../../models/user';
|
||||
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'token' parameter
|
||||
|
@ -5,7 +5,7 @@ import $ from 'cafy';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import * as speakeasy from 'speakeasy';
|
||||
import * as QRCode from 'qrcode';
|
||||
import User from '../../../models/user';
|
||||
import User from '../../../../../models/user';
|
||||
import config from '../../../../../conf';
|
||||
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import User from '../../../models/user';
|
||||
import User from '../../../../../models/user';
|
||||
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'password' parameter
|
||||
|
@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Appdata from '../../../models/appdata';
|
||||
|
||||
/**
|
||||
* Get app data
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @param {any} app
|
||||
* @param {Boolean} isSecure
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
||||
if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます');
|
||||
|
||||
// Get 'key' parameter
|
||||
const [key = null, keyError] = $(params.key).optional.nullable.string().match(/[a-z_]+/).$;
|
||||
if (keyError) return rej('invalid key param');
|
||||
|
||||
const select = {};
|
||||
if (key !== null) {
|
||||
select[`data.${key}`] = true;
|
||||
}
|
||||
const appdata = await Appdata.findOne({
|
||||
appId: app._id,
|
||||
userId: user._id
|
||||
}, {
|
||||
fields: select
|
||||
});
|
||||
|
||||
if (appdata) {
|
||||
res(appdata.data);
|
||||
} else {
|
||||
res();
|
||||
}
|
||||
});
|
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Appdata from '../../../models/appdata';
|
||||
|
||||
/**
|
||||
* Set app data
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @param {any} app
|
||||
* @param {Boolean} isSecure
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
||||
if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます');
|
||||
|
||||
// Get 'data' parameter
|
||||
const [data, dataError] = $(params.data).optional.object()
|
||||
.pipe(obj => {
|
||||
const hasInvalidData = Object.entries(obj).some(([k, v]) =>
|
||||
$(k).string().match(/^[a-z_]+$/).nok() && $(v).string().nok());
|
||||
return !hasInvalidData;
|
||||
}).$;
|
||||
if (dataError) return rej('invalid data param');
|
||||
|
||||
// Get 'key' parameter
|
||||
const [key, keyError] = $(params.key).optional.string().match(/[a-z_]+/).$;
|
||||
if (keyError) return rej('invalid key param');
|
||||
|
||||
// Get 'value' parameter
|
||||
const [value, valueError] = $(params.value).optional.string().$;
|
||||
if (valueError) return rej('invalid value param');
|
||||
|
||||
const set = {};
|
||||
if (data) {
|
||||
Object.entries(data).forEach(([k, v]) => {
|
||||
set[`data.${k}`] = v;
|
||||
});
|
||||
} else {
|
||||
set[`data.${key}`] = value;
|
||||
}
|
||||
|
||||
await Appdata.update({
|
||||
appId: app._id,
|
||||
userId: user._id
|
||||
}, Object.assign({
|
||||
appId: app._id,
|
||||
userId: user._id
|
||||
}, {
|
||||
$set: set
|
||||
}), {
|
||||
upsert: true
|
||||
});
|
||||
|
||||
res(204);
|
||||
});
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import AccessToken from '../../models/access-token';
|
||||
import { pack } from '../../models/app';
|
||||
import AccessToken from '../../../../models/access-token';
|
||||
import { pack } from '../../../../models/app';
|
||||
|
||||
/**
|
||||
* Get authorized apps of my account
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import User from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Change password
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Favorite from '../../models/favorite';
|
||||
import { pack } from '../../models/post';
|
||||
import Favorite from '../../../../models/favorite';
|
||||
import { pack } from '../../../../models/post';
|
||||
|
||||
/**
|
||||
* Get followers of a user
|
||||
|
@ -2,9 +2,9 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Notification from '../../models/notification';
|
||||
import Mute from '../../models/mute';
|
||||
import { pack } from '../../models/notification';
|
||||
import Notification from '../../../../models/notification';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { pack } from '../../../../models/notification';
|
||||
import getFriends from '../../common/get-friends';
|
||||
import read from '../../common/read-notification';
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import Post from '../../models/post';
|
||||
import { pack } from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
import Post from '../../../../models/post';
|
||||
import { pack } from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Pin post
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import User from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
import event from '../../event';
|
||||
import generateUserToken from '../../common/generate-native-user-token';
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Signin, { pack } from '../../models/signin';
|
||||
import Signin, { pack } from '../../../../models/signin';
|
||||
|
||||
/**
|
||||
* Get signin history of my account
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../models/user';
|
||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
||||
import event from '../../event';
|
||||
import config from '../../../../conf';
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User, { pack } from '../../models/user';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
import event from '../../event';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
import event from '../../event';
|
||||
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import User from '../../../../models/user';
|
||||
import event from '../../event';
|
||||
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
|
@ -2,9 +2,9 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import History from '../../models/messaging-history';
|
||||
import Mute from '../../models/mute';
|
||||
import { pack } from '../../models/messaging-message';
|
||||
import History from '../../../../models/messaging-history';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { pack } from '../../../../models/messaging-message';
|
||||
|
||||
/**
|
||||
* Show messaging history
|
||||
|
@ -2,9 +2,9 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Message from '../../models/messaging-message';
|
||||
import User from '../../models/user';
|
||||
import { pack } from '../../models/messaging-message';
|
||||
import Message from '../../../../models/messaging-message';
|
||||
import User from '../../../../models/user';
|
||||
import { pack } from '../../../../models/messaging-message';
|
||||
import read from '../../common/read-messaging-message';
|
||||
|
||||
/**
|
||||
|
@ -2,13 +2,13 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Message from '../../../models/messaging-message';
|
||||
import { isValidText } from '../../../models/messaging-message';
|
||||
import History from '../../../models/messaging-history';
|
||||
import User from '../../../models/user';
|
||||
import Mute from '../../../models/mute';
|
||||
import DriveFile from '../../../models/drive-file';
|
||||
import { pack } from '../../../models/messaging-message';
|
||||
import Message from '../../../../../models/messaging-message';
|
||||
import { isValidText } from '../../../../../models/messaging-message';
|
||||
import History from '../../../../../models/messaging-history';
|
||||
import User from '../../../../../models/user';
|
||||
import Mute from '../../../../../models/mute';
|
||||
import DriveFile from '../../../../../models/drive-file';
|
||||
import { pack } from '../../../../../models/messaging-message';
|
||||
import publishUserStream from '../../../event';
|
||||
import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../event';
|
||||
import config from '../../../../../conf';
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import Message from '../../models/messaging-message';
|
||||
import Mute from '../../models/mute';
|
||||
import Message from '../../../../models/messaging-message';
|
||||
import Mute from '../../../../models/mute';
|
||||
|
||||
/**
|
||||
* Get count of unread messages
|
||||
|
@ -4,7 +4,7 @@
|
||||
import * as os from 'os';
|
||||
import version from '../../../version';
|
||||
import config from '../../../conf';
|
||||
import Meta from '../models/meta';
|
||||
import Meta from '../../../models/meta';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@ -40,7 +40,7 @@ import Meta from '../models/meta';
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params) => new Promise(async (res, rej) => {
|
||||
const meta = (await Meta.findOne()) || {};
|
||||
const meta: any = (await Meta.findOne()) || {};
|
||||
|
||||
res({
|
||||
maintainer: config.maintainer,
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import Mute from '../../models/mute';
|
||||
import User from '../../../../models/user';
|
||||
import Mute from '../../../../models/mute';
|
||||
|
||||
/**
|
||||
* Mute a user
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import Mute from '../../models/mute';
|
||||
import User from '../../../../models/user';
|
||||
import Mute from '../../../../models/mute';
|
||||
|
||||
/**
|
||||
* Unmute a user
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Mute from '../../models/mute';
|
||||
import { pack } from '../../models/user';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { pack } from '../../../../models/user';
|
||||
import getFriends from '../../common/get-friends';
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import App, { pack } from '../../models/app';
|
||||
import App, { pack } from '../../../../models/app';
|
||||
|
||||
/**
|
||||
* Get my apps
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import Notification from '../../models/notification';
|
||||
import Mute from '../../models/mute';
|
||||
import Notification from '../../../../models/notification';
|
||||
import Mute from '../../../../models/mute';
|
||||
|
||||
/**
|
||||
* Get count of unread notifications
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import Notification from '../../models/notification';
|
||||
import Notification from '../../../../models/notification';
|
||||
import event from '../../event';
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
import $ from 'cafy';
|
||||
import OthelloGame, { pack } from '../../models/othello-game';
|
||||
import OthelloGame, { pack } from '../../../../models/othello-game';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'my' parameter
|
||||
|
@ -1,6 +1,6 @@
|
||||
import $ from 'cafy';
|
||||
import OthelloGame, { pack } from '../../../models/othello-game';
|
||||
import Othello from '../../../../common/othello/core';
|
||||
import OthelloGame, { pack } from '../../../../../models/othello-game';
|
||||
import Othello from '../../../../../common/othello/core';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'gameId' parameter
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Matching, { pack as packMatching } from '../../models/othello-matching';
|
||||
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Find session
|
||||
|
@ -1,9 +1,9 @@
|
||||
import $ from 'cafy';
|
||||
import Matching, { pack as packMatching } from '../../models/othello-matching';
|
||||
import OthelloGame, { pack as packGame } from '../../models/othello-game';
|
||||
import User from '../../models/user';
|
||||
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
|
||||
import OthelloGame, { pack as packGame } from '../../../../models/othello-game';
|
||||
import User from '../../../../models/user';
|
||||
import publishUserStream, { publishOthelloStream } from '../../event';
|
||||
import { eighteight } from '../../../common/othello/maps';
|
||||
import { eighteight } from '../../../../common/othello/maps';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Matching from '../../../models/othello-matching';
|
||||
import Matching from '../../../../../models/othello-matching';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
await Matching.remove({
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post, { pack } from '../models/post';
|
||||
import Post, { pack } from '../../../models/post';
|
||||
|
||||
/**
|
||||
* Lists all posts
|
||||
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../models/post';
|
||||
|
||||
/**
|
||||
* Categorize a post
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
if (!user.account.isPro) {
|
||||
return rej('This endpoint is available only from a Pro account');
|
||||
}
|
||||
|
||||
// Get 'postId' parameter
|
||||
const [postId, postIdErr] = $(params.postId).id().$;
|
||||
if (postIdErr) return rej('invalid postId param');
|
||||
|
||||
// Get categorizee
|
||||
const post = await Post.findOne({
|
||||
_id: postId
|
||||
});
|
||||
|
||||
if (post === null) {
|
||||
return rej('post not found');
|
||||
}
|
||||
|
||||
if (post.is_category_verified) {
|
||||
return rej('This post already has the verified category');
|
||||
}
|
||||
|
||||
// Get 'category' parameter
|
||||
const [category, categoryErr] = $(params.category).string().or([
|
||||
'music', 'game', 'anime', 'it', 'gadgets', 'photography'
|
||||
]).$;
|
||||
if (categoryErr) return rej('invalid category param');
|
||||
|
||||
// Set category
|
||||
Post.update({ _id: post._id }, {
|
||||
$set: {
|
||||
category: category,
|
||||
is_category_verified: true
|
||||
}
|
||||
});
|
||||
|
||||
// Send response
|
||||
res();
|
||||
});
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post, { pack } from '../../models/post';
|
||||
import Post, { pack } from '../../../../models/post';
|
||||
|
||||
/**
|
||||
* Show a context of a post
|
||||
|
@ -3,21 +3,21 @@
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import deepEqual = require('deep-equal');
|
||||
import parse from '../../common/text';
|
||||
import { default as Post, IPost, isValidText } from '../../models/post';
|
||||
import { default as User, ILocalAccount, IUser } from '../../models/user';
|
||||
import { default as Channel, IChannel } from '../../models/channel';
|
||||
import Following from '../../models/following';
|
||||
import Mute from '../../models/mute';
|
||||
import DriveFile from '../../models/drive-file';
|
||||
import Watching from '../../models/post-watching';
|
||||
import ChannelWatching from '../../models/channel-watching';
|
||||
import { pack } from '../../models/post';
|
||||
import parse from '../../../../common/text';
|
||||
import { default as Post, IPost, isValidText } from '../../../../models/post';
|
||||
import { default as User, ILocalAccount, IUser } from '../../../../models/user';
|
||||
import { default as Channel, IChannel } from '../../../../models/channel';
|
||||
import Following from '../../../../models/following';
|
||||
import Mute from '../../../../models/mute';
|
||||
import DriveFile from '../../../../models/drive-file';
|
||||
import Watching from '../../../../models/post-watching';
|
||||
import ChannelWatching from '../../../../models/channel-watching';
|
||||
import { pack } from '../../../../models/post';
|
||||
import notify from '../../common/notify';
|
||||
import watch from '../../common/watch-post';
|
||||
import event, { pushSw, publishChannelStream } from '../../event';
|
||||
import getAcct from '../../../common/user/get-acct';
|
||||
import parseAcct from '../../../common/user/parse-acct';
|
||||
import getAcct from '../../../../common/user/get-acct';
|
||||
import parseAcct from '../../../../common/user/parse-acct';
|
||||
import config from '../../../../conf';
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Favorite from '../../../models/favorite';
|
||||
import Post from '../../../models/post';
|
||||
import Favorite from '../../../../../models/favorite';
|
||||
import Post from '../../../../../models/post';
|
||||
|
||||
/**
|
||||
* Favorite a post
|
||||
|
@ -2,8 +2,8 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Favorite from '../../../models/favorite';
|
||||
import Post from '../../../models/post';
|
||||
import Favorite from '../../../../../models/favorite';
|
||||
import Post from '../../../../../models/post';
|
||||
|
||||
/**
|
||||
* Unfavorite a post
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user