refactor: Use ===
This commit is contained in:
parent
fef5ec874b
commit
d4a630902d
|
@ -99,7 +99,7 @@ async function isPortAvailable(port: number): Promise<boolean> {
|
||||||
function showEnvironment(): void {
|
function showEnvironment(): void {
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
const logger = bootLogger.createSubLogger('env');
|
const logger = bootLogger.createSubLogger('env');
|
||||||
logger.info(typeof env == 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`);
|
logger.info(typeof env === 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`);
|
||||||
|
|
||||||
if (env !== 'production') {
|
if (env !== 'production') {
|
||||||
logger.warn('The environment is not in production mode.');
|
logger.warn('The environment is not in production mode.');
|
||||||
|
|
|
@ -310,7 +310,7 @@ export default Vue.extend({
|
||||||
title: this.$t('search'),
|
title: this.$t('search'),
|
||||||
input: true
|
input: true
|
||||||
}).then(async ({ canceled, result: query }) => {
|
}).then(async ({ canceled, result: query }) => {
|
||||||
if (canceled || query == null || query == '') return;
|
if (canceled || query == null || query === '') return;
|
||||||
|
|
||||||
this.searching = true;
|
this.searching = true;
|
||||||
search(this, query).finally(() => {
|
search(this, query).finally(() => {
|
||||||
|
@ -320,7 +320,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
searchKeypress(e) {
|
searchKeypress(e) {
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode === 13) {
|
||||||
this.searchWait = true;
|
this.searchWait = true;
|
||||||
search(this, this.searchQuery).finally(() => {
|
search(this, this.searchQuery).finally(() => {
|
||||||
this.searchWait = false;
|
this.searchWait = false;
|
||||||
|
|
|
@ -197,7 +197,7 @@ export default class MiOS extends EventEmitter {
|
||||||
// When subscribe failed
|
// When subscribe failed
|
||||||
.catch(async (err: Error) => {
|
.catch(async (err: Error) => {
|
||||||
// 通知が許可されていなかったとき
|
// 通知が許可されていなかったとき
|
||||||
if (err.name == 'NotAllowedError') {
|
if (err.name === 'NotAllowedError') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,9 @@ const ignoreElemens = ['input', 'textarea'];
|
||||||
function match(e: KeyboardEvent, patterns: action['patterns']): boolean {
|
function match(e: KeyboardEvent, patterns: action['patterns']): boolean {
|
||||||
const key = e.code.toLowerCase();
|
const key = e.code.toLowerCase();
|
||||||
return patterns.some(pattern => pattern.which.includes(key) &&
|
return patterns.some(pattern => pattern.which.includes(key) &&
|
||||||
pattern.ctrl == e.ctrlKey &&
|
pattern.ctrl === e.ctrlKey &&
|
||||||
pattern.shift == e.shiftKey &&
|
pattern.shift === e.shiftKey &&
|
||||||
pattern.alt == e.altKey &&
|
pattern.alt === e.altKey &&
|
||||||
!e.metaKey
|
!e.metaKey
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default (input: string): string[] => {
|
export default (input: string): string[] => {
|
||||||
if (Object.keys(aliases).some(a => a.toLowerCase() == input.toLowerCase())) {
|
if (Object.keys(aliases).some(a => a.toLowerCase() === input.toLowerCase())) {
|
||||||
const codes = aliases[input];
|
const codes = aliases[input];
|
||||||
return Array.isArray(codes) ? codes : [codes];
|
return Array.isArray(codes) ? codes : [codes];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export default (opts) => ({
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
empty(): boolean {
|
empty(): boolean {
|
||||||
return this.items.length == 0 && !this.fetching && this.inited;
|
return this.items.length === 0 && !this.fetching && this.inited;
|
||||||
},
|
},
|
||||||
|
|
||||||
error(): boolean {
|
error(): boolean {
|
||||||
|
|
|
@ -47,9 +47,9 @@ export async function search(v: any, q: string) {
|
||||||
uri: q
|
uri: q
|
||||||
});
|
});
|
||||||
dialog.close();
|
dialog.close();
|
||||||
if (res.type == 'User') {
|
if (res.type === 'User') {
|
||||||
v.$router.push(`/@${res.object.username}@${res.object.host}`);
|
v.$router.push(`/@${res.object.username}@${res.object.host}`);
|
||||||
} else if (res.type == 'Note') {
|
} else if (res.type === 'Note') {
|
||||||
v.$router.push(`/notes/${res.object.id}`);
|
v.$router.push(`/notes/${res.object.id}`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default class Stream extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
private onOpen() {
|
private onOpen() {
|
||||||
const isReconnect = this.state == 'reconnecting';
|
const isReconnect = this.state === 'reconnecting';
|
||||||
|
|
||||||
this.state = 'connected';
|
this.state = 'connected';
|
||||||
this.emit('_connected_');
|
this.emit('_connected_');
|
||||||
|
@ -87,7 +87,7 @@ export default class Stream extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
private onClose() {
|
private onClose() {
|
||||||
if (this.state == 'connected') {
|
if (this.state === 'connected') {
|
||||||
this.state = 'reconnecting';
|
this.state = 'reconnecting';
|
||||||
this.emit('_disconnected_');
|
this.emit('_disconnected_');
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ export default class Stream extends EventEmitter {
|
||||||
private onMessage(message) {
|
private onMessage(message) {
|
||||||
const { type, body } = JSON.parse(message.data);
|
const { type, body } = JSON.parse(message.data);
|
||||||
|
|
||||||
if (type == 'channel') {
|
if (type === 'channel') {
|
||||||
const id = body.id;
|
const id = body.id;
|
||||||
|
|
||||||
let connections: Connection[];
|
let connections: Connection[];
|
||||||
|
|
|
@ -257,7 +257,7 @@ export default () => new Vuex.Store({
|
||||||
},
|
},
|
||||||
|
|
||||||
updateWidget(state, x) {
|
updateWidget(state, x) {
|
||||||
const w = state.widgets.find(w => w.id == x.id);
|
const w = state.widgets.find(w => w.id === x.id);
|
||||||
if (w) {
|
if (w) {
|
||||||
w.data = x.data;
|
w.data = x.data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,14 +51,14 @@ export default Vue.extend({
|
||||||
weekday: date.getDay()
|
weekday: date.getDay()
|
||||||
};
|
};
|
||||||
|
|
||||||
d.v = peak == 0 ? 0 : d.total / (peak / 2);
|
d.v = peak === 0 ? 0 : d.total / (peak / 2);
|
||||||
if (d.v > 1) d.v = 1;
|
if (d.v > 1) d.v = 1;
|
||||||
const ch = d.date.weekday == 0 || d.date.weekday == 6 ? 275 : 170;
|
const ch = d.date.weekday === 0 || d.date.weekday === 6 ? 275 : 170;
|
||||||
const cs = d.v * 100;
|
const cs = d.v * 100;
|
||||||
const cl = 15 + ((1 - d.v) * 80);
|
const cl = 15 + ((1 - d.v) * 80);
|
||||||
d.color = `hsl(${ch}, ${cs}%, ${cl}%)`;
|
d.color = `hsl(${ch}, ${cs}%, ${cl}%)`;
|
||||||
|
|
||||||
if (d.date.weekday == 0) x--;
|
if (d.date.weekday === 0) x--;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default define({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
func() {
|
func() {
|
||||||
if (this.props.design == 2) {
|
if (this.props.design === 2) {
|
||||||
this.props.design = 0;
|
this.props.design = 0;
|
||||||
} else {
|
} else {
|
||||||
this.props.design++;
|
this.props.design++;
|
||||||
|
@ -68,7 +68,7 @@ export default define({
|
||||||
this.save();
|
this.save();
|
||||||
},
|
},
|
||||||
toggleView() {
|
toggleView() {
|
||||||
if (this.props.view == 1) {
|
if (this.props.view === 1) {
|
||||||
this.props.view = 0;
|
this.props.view = 0;
|
||||||
} else {
|
} else {
|
||||||
this.props.view++;
|
this.props.view++;
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default define({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
func() {
|
func() {
|
||||||
if (this.props.design == 2) {
|
if (this.props.design === 2) {
|
||||||
this.props.design = 0;
|
this.props.design = 0;
|
||||||
} else {
|
} else {
|
||||||
this.props.design++;
|
this.props.design++;
|
||||||
|
@ -102,7 +102,7 @@ export default define({
|
||||||
this.monthP = monthNumer / monthDenom * 100;
|
this.monthP = monthNumer / monthDenom * 100;
|
||||||
this.yearP = yearNumer / yearDenom * 100;
|
this.yearP = yearNumer / yearDenom * 100;
|
||||||
|
|
||||||
this.isHoliday = now.getDay() == 0 || now.getDay() == 6;
|
this.isHoliday = now.getDay() === 0 || now.getDay() === 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<mk-container :show-header="props.design === 0" :naked="props.design === 2" :class="$style.root" :data-melt="props.design == 2">
|
<mk-container :show-header="props.design === 0" :naked="props.design === 2" :class="$style.root" :data-melt="props.design === 2">
|
||||||
<template #header><fa :icon="faCamera"/>{{ $t('_widgets.photos') }}</template>
|
<template #header><fa :icon="faCamera"/>{{ $t('_widgets.photos') }}</template>
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
|
@ -66,7 +66,7 @@ export default define({
|
||||||
},
|
},
|
||||||
|
|
||||||
func() {
|
func() {
|
||||||
if (this.props.design == 2) {
|
if (this.props.design === 2) {
|
||||||
this.props.design = 0;
|
this.props.design = 0;
|
||||||
} else {
|
} else {
|
||||||
this.props.design++;
|
this.props.design++;
|
||||||
|
|
|
@ -15,7 +15,7 @@ const dir = `${__dirname}/../../.config`;
|
||||||
/**
|
/**
|
||||||
* Path of configuration file
|
* Path of configuration file
|
||||||
*/
|
*/
|
||||||
const path = process.env.NODE_ENV == 'test'
|
const path = process.env.NODE_ENV === 'test'
|
||||||
? `${dir}/test.yml`
|
? `${dir}/test.yml`
|
||||||
: `${dir}/default.yml`;
|
: `${dir}/default.yml`;
|
||||||
|
|
||||||
|
|
|
@ -226,10 +226,10 @@ export default class Reversi {
|
||||||
// 座標が指し示す位置がボード外に出たとき
|
// 座標が指し示す位置がボード外に出たとき
|
||||||
if (this.opts.loopedBoard && this.transformXyToPos(
|
if (this.opts.loopedBoard && this.transformXyToPos(
|
||||||
(x = ((x % this.mapWidth) + this.mapWidth) % this.mapWidth),
|
(x = ((x % this.mapWidth) + this.mapWidth) % this.mapWidth),
|
||||||
(y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) == initPos)
|
(y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) === initPos)
|
||||||
// 盤面の境界でループし、自分が石を置く位置に戻ってきたとき、挟めるようにしている (ref: Test4のマップ)
|
// 盤面の境界でループし、自分が石を置く位置に戻ってきたとき、挟めるようにしている (ref: Test4のマップ)
|
||||||
return found;
|
return found;
|
||||||
else if (x == -1 || y == -1 || x == this.mapWidth || y == this.mapHeight)
|
else if (x === -1 || y === -1 || x === this.mapWidth || y === this.mapHeight)
|
||||||
return []; // 挟めないことが確定 (盤面外に到達)
|
return []; // 挟めないことが確定 (盤面外に到達)
|
||||||
|
|
||||||
const pos = this.transformXyToPos(x, y);
|
const pos = this.transformXyToPos(x, y);
|
||||||
|
|
|
@ -13,7 +13,7 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||||
return text.trim();
|
return text.trim();
|
||||||
|
|
||||||
function getText(node: any): string {
|
function getText(node: any): string {
|
||||||
if (node.nodeName == '#text') return node.value;
|
if (node.nodeName === '#text') return node.value;
|
||||||
|
|
||||||
if (node.childNodes) {
|
if (node.childNodes) {
|
||||||
return node.childNodes.map((n: any) => getText(n)).join('');
|
return node.childNodes.map((n: any) => getText(n)).join('');
|
||||||
|
@ -34,8 +34,8 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
const txt = getText(node);
|
const txt = getText(node);
|
||||||
const rel = node.attrs.find((x: any) => x.name == 'rel');
|
const rel = node.attrs.find((x: any) => x.name === 'rel');
|
||||||
const href = node.attrs.find((x: any) => x.name == 'href');
|
const href = node.attrs.find((x: any) => x.name === 'href');
|
||||||
|
|
||||||
// ハッシュタグ
|
// ハッシュタグ
|
||||||
if (hashtagNames && href && hashtagNames.map(x => x.toLowerCase()).includes(txt.toLowerCase())) {
|
if (hashtagNames && href && hashtagNames.map(x => x.toLowerCase()).includes(txt.toLowerCase())) {
|
||||||
|
@ -44,12 +44,12 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||||
} else if (txt.startsWith('@') && !(rel && rel.value.match(/^me /))) {
|
} else if (txt.startsWith('@') && !(rel && rel.value.match(/^me /))) {
|
||||||
const part = txt.split('@');
|
const part = txt.split('@');
|
||||||
|
|
||||||
if (part.length == 2) {
|
if (part.length === 2) {
|
||||||
//#region ホスト名部分が省略されているので復元する
|
//#region ホスト名部分が省略されているので復元する
|
||||||
const acct = `${txt}@${(new URL(href.value)).hostname}`;
|
const acct = `${txt}@${(new URL(href.value)).hostname}`;
|
||||||
text += acct;
|
text += acct;
|
||||||
//#endregion
|
//#endregion
|
||||||
} else if (part.length == 3) {
|
} else if (part.length === 3) {
|
||||||
text += txt;
|
text += txt;
|
||||||
}
|
}
|
||||||
// その他
|
// その他
|
||||||
|
|
|
@ -31,7 +31,7 @@ export const mfmLanguage = P.createLanguage({
|
||||||
r.center,
|
r.center,
|
||||||
),
|
),
|
||||||
startOfLine: () => P((input, i) => {
|
startOfLine: () => P((input, i) => {
|
||||||
if (i == 0 || input[i] == '\n' || input[i - 1] == '\n') {
|
if (i === 0 || input[i] === '\n' || input[i - 1] === '\n') {
|
||||||
return P.makeSuccess(i, null);
|
return P.makeSuccess(i, null);
|
||||||
} else {
|
} else {
|
||||||
return P.makeFailure(i, 'not newline');
|
return P.makeFailure(i, 'not newline');
|
||||||
|
@ -50,7 +50,7 @@ export const mfmLanguage = P.createLanguage({
|
||||||
if (!text.match(/^>[\s\S]+?/)) return P.makeFailure(i, 'not a quote');
|
if (!text.match(/^>[\s\S]+?/)) return P.makeFailure(i, 'not a quote');
|
||||||
const quote = takeWhile(line => line.startsWith('>'), text.split('\n'));
|
const quote = takeWhile(line => line.startsWith('>'), text.split('\n'));
|
||||||
const qInner = quote.join('\n').replace(/^>/gm, '').replace(/^ /gm, '');
|
const qInner = quote.join('\n').replace(/^>/gm, '').replace(/^ /gm, '');
|
||||||
if (qInner == '') return P.makeFailure(i, 'not a quote');
|
if (qInner === '') return P.makeFailure(i, 'not a quote');
|
||||||
const contents = r.root.tryParse(qInner);
|
const contents = r.root.tryParse(qInner);
|
||||||
return P.makeSuccess(i + quote.join('\n').length + 1, createTree('quote', contents, {}));
|
return P.makeSuccess(i + quote.join('\n').length + 1, createTree('quote', contents, {}));
|
||||||
})),
|
})),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { MfmForest, MfmTree } from './prelude';
|
||||||
import { createTree, createLeaf } from '../prelude/tree';
|
import { createTree, createLeaf } from '../prelude/tree';
|
||||||
|
|
||||||
function isEmptyTextTree(t: MfmTree): boolean {
|
function isEmptyTextTree(t: MfmTree): boolean {
|
||||||
return t.node.type == 'text' && t.node.props.text === '';
|
return t.node.type === 'text' && t.node.props.text === '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function concatTextTrees(ts: MfmForest): MfmTree {
|
function concatTextTrees(ts: MfmForest): MfmTree {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { MfmForest } from './prelude';
|
||||||
import { normalize } from './normalize';
|
import { normalize } from './normalize';
|
||||||
|
|
||||||
export function parse(source: string | null): MfmForest | null {
|
export function parse(source: string | null): MfmForest | null {
|
||||||
if (source == null || source == '') {
|
if (source == null || source === '') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export function parse(source: string | null): MfmForest | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parsePlain(source: string | null): MfmForest | null {
|
export function parsePlain(source: string | null): MfmForest | null {
|
||||||
if (source == null || source == '') {
|
if (source == null || source === '') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class NoteRepository extends Repository<Note> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
|
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
|
||||||
if (packedNote.visibility == 'followers') {
|
if (packedNote.visibility === 'followers') {
|
||||||
if (meId == null) {
|
if (meId == null) {
|
||||||
hide = true;
|
hide = true;
|
||||||
} else if (meId === packedNote.userId) {
|
} else if (meId === packedNote.userId) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { IFollow } from '../../type';
|
||||||
import { Users } from '../../../../models';
|
import { Users } from '../../../../models';
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
const id = typeof activity.actor == 'string' ? activity.actor : activity.actor.id;
|
const id = typeof activity.actor === 'string' ? activity.actor : activity.actor.id;
|
||||||
if (id == null) throw new Error('missing id');
|
if (id == null) throw new Error('missing id');
|
||||||
|
|
||||||
if (!id.startsWith(config.url + '/')) {
|
if (!id.startsWith(config.url + '/')) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { IFollow } from '../type';
|
||||||
import { Users } from '../../../models';
|
import { Users } from '../../../models';
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
const id = typeof activity.object === 'string' ? activity.object : activity.object.id;
|
||||||
if (id == null) throw new Error('missing id');
|
if (id == null) throw new Error('missing id');
|
||||||
|
|
||||||
if (!id.startsWith(config.url + '/')) {
|
if (!id.startsWith(config.url + '/')) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { IFollow } from '../../type';
|
||||||
import { Users } from '../../../../models';
|
import { Users } from '../../../../models';
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
const id = typeof activity.actor == 'string' ? activity.actor : activity.actor.id;
|
const id = typeof activity.actor === 'string' ? activity.actor : activity.actor.id;
|
||||||
if (id == null) throw new Error('missing id');
|
if (id == null) throw new Error('missing id');
|
||||||
|
|
||||||
if (!id.startsWith(config.url + '/')) {
|
if (!id.startsWith(config.url + '/')) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Users } from '../../../../models';
|
||||||
const logger = apLogger;
|
const logger = apLogger;
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => {
|
||||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
const id = typeof activity.object === 'string' ? activity.object : activity.object.id;
|
||||||
if (id == null) throw new Error('missing id');
|
if (id == null) throw new Error('missing id');
|
||||||
|
|
||||||
const uri = activity.id || activity;
|
const uri = activity.id || activity;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { IRemoteUser } from '../../../../models/entities/user';
|
||||||
import { Users, FollowRequests, Followings } from '../../../../models';
|
import { Users, FollowRequests, Followings } from '../../../../models';
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
const id = typeof activity.object === 'string' ? activity.object : activity.object.id;
|
||||||
if (id == null) throw new Error('missing id');
|
if (id == null) throw new Error('missing id');
|
||||||
|
|
||||||
if (!id.startsWith(config.url + '/')) {
|
if (!id.startsWith(config.url + '/')) {
|
||||||
|
|
|
@ -293,7 +293,7 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
|
||||||
* リモートサーバーからフェッチしてMisskeyに登録しそれを返します。
|
* リモートサーバーからフェッチしてMisskeyに登録しそれを返します。
|
||||||
*/
|
*/
|
||||||
export async function resolveNote(value: string | IObject, resolver?: Resolver): Promise<Note | null> {
|
export async function resolveNote(value: string | IObject, resolver?: Resolver): Promise<Note | null> {
|
||||||
const uri = typeof value == 'string' ? value : value.id;
|
const uri = typeof value === 'string' ? value : value.id;
|
||||||
if (uri == null) throw new Error('missing uri');
|
if (uri == null) throw new Error('missing uri');
|
||||||
|
|
||||||
// ブロックしてたら中断
|
// ブロックしてたら中断
|
||||||
|
|
|
@ -136,7 +136,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
|
||||||
|
|
||||||
const tags = extractApHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 32);
|
const tags = extractApHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 32);
|
||||||
|
|
||||||
const isBot = object.type == 'Service';
|
const isBot = object.type === 'Service';
|
||||||
|
|
||||||
// Create user
|
// Create user
|
||||||
let user: IRemoteUser;
|
let user: IRemoteUser;
|
||||||
|
@ -327,7 +327,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
|
||||||
emojis: emojiNames,
|
emojis: emojiNames,
|
||||||
name: person.name,
|
name: person.name,
|
||||||
tags,
|
tags,
|
||||||
isBot: object.type == 'Service',
|
isBot: object.type === 'Service',
|
||||||
isCat: (person as any).isCat === true,
|
isCat: (person as any).isCat === true,
|
||||||
isLocked: !!person.manuallyApprovesFollowers,
|
isLocked: !!person.manuallyApprovesFollowers,
|
||||||
} as Partial<User>;
|
} as Partial<User>;
|
||||||
|
|
|
@ -41,7 +41,7 @@ export async function extractPollFromQuestion(source: string | IObject, resolver
|
||||||
* @returns true if updated
|
* @returns true if updated
|
||||||
*/
|
*/
|
||||||
export async function updateQuestion(value: any) {
|
export async function updateQuestion(value: any) {
|
||||||
const uri = typeof value == 'string' ? value : value.id;
|
const uri = typeof value === 'string' ? value : value.id;
|
||||||
|
|
||||||
// URIがこのサーバーを指しているならスキップ
|
// URIがこのサーバーを指しているならスキップ
|
||||||
if (uri.startsWith(config.url + '/')) throw new Error('uri points local');
|
if (uri.startsWith(config.url + '/')) throw new Error('uri points local');
|
||||||
|
|
|
@ -7,10 +7,10 @@ export default (object: any, note: Note) => {
|
||||||
let to: string[] = [];
|
let to: string[] = [];
|
||||||
let cc: string[] = [];
|
let cc: string[] = [];
|
||||||
|
|
||||||
if (note.visibility == 'public') {
|
if (note.visibility === 'public') {
|
||||||
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
cc = [`${attributedTo}/followers`];
|
cc = [`${attributedTo}/followers`];
|
||||||
} else if (note.visibility == 'home') {
|
} else if (note.visibility === 'home') {
|
||||||
to = [`${attributedTo}/followers`];
|
to = [`${attributedTo}/followers`];
|
||||||
cc = ['https://www.w3.org/ns/activitystreams#Public'];
|
cc = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -63,13 +63,13 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
|
||||||
let to: string[] = [];
|
let to: string[] = [];
|
||||||
let cc: string[] = [];
|
let cc: string[] = [];
|
||||||
|
|
||||||
if (note.visibility == 'public') {
|
if (note.visibility === 'public') {
|
||||||
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
cc = [`${attributedTo}/followers`].concat(mentions);
|
cc = [`${attributedTo}/followers`].concat(mentions);
|
||||||
} else if (note.visibility == 'home') {
|
} else if (note.visibility === 'home') {
|
||||||
to = [`${attributedTo}/followers`];
|
to = [`${attributedTo}/followers`];
|
||||||
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
|
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
|
||||||
} else if (note.visibility == 'followers') {
|
} else if (note.visibility === 'followers') {
|
||||||
to = [`${attributedTo}/followers`];
|
to = [`${attributedTo}/followers`];
|
||||||
cc = mentions;
|
cc = mentions;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -101,7 +101,7 @@ export default async (ctx: Router.RouterContext) => {
|
||||||
* @param note Note
|
* @param note Note
|
||||||
*/
|
*/
|
||||||
export async function packActivity(note: Note): Promise<any> {
|
export async function packActivity(note: Note): Promise<any> {
|
||||||
if (note.renoteId && note.text == null && !note.hasPoll && (note.fileIds == null || note.fileIds.length == 0)) {
|
if (note.renoteId && note.text == null && !note.hasPoll && (note.fileIds == null || note.fileIds.length === 0)) {
|
||||||
const renote = await Notes.findOne(note.renoteId).then(ensure);
|
const renote = await Notes.findOne(note.renoteId).then(ensure);
|
||||||
return renderAnnounce(renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`, note);
|
return renderAnnounce(renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`, note);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ function verifyCertificateChain(certificates: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function PEMString(pemBuffer: Buffer, type = 'CERTIFICATE') {
|
function PEMString(pemBuffer: Buffer, type = 'CERTIFICATE') {
|
||||||
if (pemBuffer.length == 65 && pemBuffer[0] == 0x04) {
|
if (pemBuffer.length === 65 && pemBuffer[0] === 0x04) {
|
||||||
pemBuffer = Buffer.concat([PEM_PRELUDE, pemBuffer], 91);
|
pemBuffer = Buffer.concat([PEM_PRELUDE, pemBuffer], 91);
|
||||||
type = 'PUBLIC KEY';
|
type = 'PUBLIC KEY';
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
|
||||||
call(endpoint.name, user, app, body, (ctx as any).file).then((res: any) => {
|
call(endpoint.name, user, app, body, (ctx as any).file).then((res: any) => {
|
||||||
reply(res);
|
reply(res);
|
||||||
}).catch((e: ApiError) => {
|
}).catch((e: ApiError) => {
|
||||||
reply(e.httpStatusCode ? e.httpStatusCode : e.kind == 'client' ? 400 : 500, e);
|
reply(e.httpStatusCode ? e.httpStatusCode : e.kind === 'client' ? 400 : 500, e);
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
reply(403, new ApiError({
|
reply(403, new ApiError({
|
||||||
|
|
|
@ -51,8 +51,8 @@ const sort: any = { // < https://github.com/Microsoft/TypeScript/issues/1863
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, async (ps, me) => {
|
||||||
const q = {} as any;
|
const q = {} as any;
|
||||||
|
|
||||||
if (ps.origin == 'local') q['userHost'] = null;
|
if (ps.origin === 'local') q['userHost'] = null;
|
||||||
if (ps.origin == 'remote') q['userHost'] = { $ne: null };
|
if (ps.origin === 'remote') q['userHost'] = { $ne: null };
|
||||||
|
|
||||||
const files = await DriveFiles.find({
|
const files = await DriveFiles.find({
|
||||||
where: q,
|
where: q,
|
||||||
|
|
|
@ -193,14 +193,14 @@ export default define(meta, async (ps, user, token) => {
|
||||||
if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday;
|
if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday;
|
||||||
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;
|
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;
|
||||||
if (ps.bannerId !== undefined) updates.bannerId = ps.bannerId;
|
if (ps.bannerId !== undefined) updates.bannerId = ps.bannerId;
|
||||||
if (typeof ps.isLocked == 'boolean') updates.isLocked = ps.isLocked;
|
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
|
||||||
if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
|
if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot;
|
||||||
if (typeof ps.carefulBot == 'boolean') profileUpdates.carefulBot = ps.carefulBot;
|
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
|
||||||
if (typeof ps.autoAcceptFollowed == 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||||
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
|
if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat;
|
||||||
if (typeof ps.autoWatch == 'boolean') profileUpdates.autoWatch = ps.autoWatch;
|
if (typeof ps.autoWatch === 'boolean') profileUpdates.autoWatch = ps.autoWatch;
|
||||||
if (typeof ps.injectFeaturedNote == 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
||||||
if (typeof ps.alwaysMarkNsfw == 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
if (typeof ps.alwaysMarkNsfw === 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
||||||
|
|
||||||
if (ps.avatarId) {
|
if (ps.avatarId) {
|
||||||
const avatar = await DriveFiles.findOne(ps.avatarId);
|
const avatar = await DriveFiles.findOne(ps.avatarId);
|
||||||
|
|
|
@ -54,7 +54,7 @@ module.exports = (server: http.Server) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on('message', async (data) => {
|
connection.on('message', async (data) => {
|
||||||
if (data.utf8Data == 'ping') {
|
if (data.utf8Data === 'ping') {
|
||||||
connection.send('pong');
|
connection.send('pong');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -150,7 +150,7 @@ export default () => new Promise(resolve => {
|
||||||
|
|
||||||
// Bulk write
|
// Bulk write
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (queue.length == 0) return;
|
if (queue.length === 0) return;
|
||||||
|
|
||||||
const requests = queue.length;
|
const requests = queue.length;
|
||||||
const time = sum(queue.map(x => x.time));
|
const time = sum(queue.map(x => x.time));
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default async function(userId: string, type: string, body?: any) {
|
||||||
//swLogger.info(err.headers);
|
//swLogger.info(err.headers);
|
||||||
//swLogger.info(err.body);
|
//swLogger.info(err.body);
|
||||||
|
|
||||||
if (err.statusCode == 410) {
|
if (err.statusCode === 410) {
|
||||||
SwSubscriptions.delete({
|
SwSubscriptions.delete({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
endpoint: subscription.endpoint,
|
endpoint: subscription.endpoint,
|
||||||
|
|
|
@ -18,7 +18,7 @@ class WebpackOnBuildPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV == 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
const locales = require('./locales');
|
const locales = require('./locales');
|
||||||
const meta = require('./package.json');
|
const meta = require('./package.json');
|
||||||
|
|
Loading…
Reference in New Issue