Compare commits

...

49 Commits

Author SHA1 Message Date
9df81d1939 10.10.0 2018-10-12 14:38:21 +09:00
3be0079868 Merge pull request #2890 from syuilo/l10n_develop
New Crowdin translations
2018-10-12 14:36:54 +09:00
9b253ccb3a Refactor 2018-10-12 14:34:54 +09:00
dded76099c Refactor and usability improvements 2018-10-12 14:28:48 +09:00
41a7ec7d3d Fix bug 2018-10-12 13:53:40 +09:00
168c773ba0 Fix user recommendation query (last activity) (#2892) 2018-10-12 13:48:26 +09:00
9abed92196 New translations ja-JP.yml (French) 2018-10-12 05:26:16 +09:00
4a75e3602a New translations ja-JP.yml (French) 2018-10-12 05:13:53 +09:00
1a689f6641 削除された投稿はタイムライン上で表示しないようにする (#2887)
* Excepts deleted notes on query

* Hide deleted notes

* Use v-show
2018-10-12 05:10:40 +09:00
9535759787 trim filename 2018-10-12 04:01:45 +09:00
f8fc31f14a スクロール時に新着情報を取得した際に、アイコンが被るのを修正 (#2888) 2018-10-12 03:28:37 +09:00
b74bf97761 10.9.2 2018-10-11 23:52:18 +09:00
a090b908bd Fix bug 2018-10-11 23:52:11 +09:00
3046821026 10.9.1 2018-10-11 23:09:12 +09:00
e94c73efe2 Fix 2018-10-11 23:07:20 +09:00
e85f9f4aa5 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視するように 2018-10-11 23:01:57 +09:00
ad67886f96 Resolve #543 2018-10-11 22:35:34 +09:00
5df0e102fd Fix 2018-10-11 22:17:27 +09:00
a04f0e3545 10.9.0 2018-10-11 21:27:33 +09:00
dff9c7ac48 Clean up and fix 2018-10-11 21:25:55 +09:00
3a80b59986 並列に処理するように 2018-10-11 21:14:20 +09:00
07560a4fdd 10.8.0 2018-10-11 18:38:31 +09:00
7edca21c05 Merge branch 'develop' of https://github.com/syuilo/misskey into develop 2018-10-11 18:35:50 +09:00
34105abd9d Fix 2018-10-11 18:35:19 +09:00
1bbca48a0b Update setup.ja.md 2018-10-11 18:20:27 +09:00
21f6a86772 Update setup.ja.md 2018-10-11 18:18:15 +09:00
6559197c55 Clean up 2018-10-11 18:10:41 +09:00
05f9ad11bb Redisがインストールされているときはイベントの共有にRedisのpub/subを使うように 2018-10-11 18:09:41 +09:00
f06d586680 10.7.2 2018-10-11 17:27:39 +09:00
4f45e8125c Fix 2018-10-11 17:25:53 +09:00
cc2843503d 10.7.1 2018-10-11 17:00:48 +09:00
324a974dec Fix bug 2018-10-11 17:00:22 +09:00
4d4ffd70ac 10.7.0 2018-10-11 15:58:39 +09:00
bf98a11b65 Reduce memory usage in file migration tool 2018-10-11 15:56:18 +09:00
1117ce4b54 Redisをオプションにしたり 2018-10-11 15:50:27 +09:00
57e93b9b4e fix(package): update @types/node to version 10.11.7 (#2885) 2018-10-11 05:41:01 +09:00
9e4b061ed0 Fix bug 2018-10-11 05:26:51 +09:00
1067bef7d6 Fix bug 2018-10-11 05:26:09 +09:00
8bff529acd Merge branch 'develop' of https://github.com/syuilo/misskey into develop 2018-10-11 02:48:32 +09:00
4b08677839 ✌️ 2018-10-11 02:48:19 +09:00
70997cb551 fix(package): update vue-color to version 2.7.0 (#2884) 2018-10-11 02:22:57 +09:00
bf0ef17e23 Improve error logs 2018-10-11 02:19:21 +09:00
7dae5107f8 Improve fault tolerance 2018-10-11 02:11:12 +09:00
2dea88a147 Update stream.ts 2018-10-10 22:13:32 +09:00
b9290a021b New translations ja-JP.yml (French) 2018-10-10 07:51:07 +09:00
129ce93868 New translations ja-JP.yml (French) 2018-10-10 07:41:10 +09:00
5f41e5d6d0 New translations ja-JP.yml (French) 2018-10-10 07:31:22 +09:00
c706d030ea New translations ja-JP.yml (French) 2018-10-10 07:21:14 +09:00
34716a34f8 New translations ja-JP.yml (French) 2018-10-10 07:02:04 +09:00
50 changed files with 633 additions and 563 deletions

View File

@ -60,11 +60,6 @@ mongodb:
user: example-misskey-user
pass: example-misskey-pass
redis:
host: localhost
port: 6379
pass: example-pass
# Drive capacity of a local user (MB)
localDriveCapacityMb: 256
@ -122,47 +117,50 @@ drive:
# Below settings are optional
#
# Redis
#redis:
# host: localhost
# port: 6379
# pass: example-pass
# Elasticsearch
# elasticsearch:
# host: localhost
# port: 9200
# pass: null
#elasticsearch:
# host: localhost
# port: 9200
# pass: null
# reCAPTCHA
# recaptcha:
# site_key: example-site-key
#recaptcha:
# site_key: example-site-key
# secret_key: example-secret-key
# ServiceWorker
# sw:
# # Public key of VAPID
# public_key: example-sw-public-key
# # Private key of VAPID
# private_key: example-sw-private-key
# google_maps_api_key: example-google-maps-api-key
#sw:
# # Public key of VAPID
# public_key: example-sw-public-key
#
# # Private key of VAPID
# private_key: example-sw-private-key
# Twitter integration
# You need to set the oauth callback url as : https://<your-misskey-instance>/api/tw/cb
# twitter:
# consumer_key: example-twitter-consumer-key
# consumer_secret: example-twitter-consumer-secret-key
#twitter:
# consumer_key: example-twitter-consumer-key
# consumer_secret: example-twitter-consumer-secret-key
# Ghost
# Ghost account is an account used for the purpose of delegating
# followers when putting users in the list.
# ghost: user-id-of-your-ghost-account
#ghost: user-id-of-your-ghost-account
# Clustering
# clusterLimit: 1
#clusterLimit: 1
# Summaly proxy
# summalyProxy: "http://example.com"
#summalyProxy: "http://example.com"
# User recommendation
user_recommendation:
external: true
engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}}
timeout: 300000
#user_recommendation:
# external: true
# engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}}
# timeout: 300000

View File

@ -24,12 +24,12 @@ Please install and setup these softwares:
#### Dependencies :package:
* **[Node.js](https://nodejs.org/en/)**
* **[MongoDB](https://www.mongodb.com/)** >= 3.6
* **[Redis](https://redis.io/)**
##### Optional
* [Redis](https://redis.io/)
* Redis is optional, but we strongly recommended to install it
* [Elasticsearch](https://www.elastic.co/) - used to provide searching feature instead of MongoDB
*3.* Setup MongoDB
----------------------------------------------------------------
In root :

View File

@ -24,10 +24,17 @@ adduser --disabled-password --disabled-login misskey
#### 依存関係 :package:
* **[Node.js](https://nodejs.org/en/)**
* **[MongoDB](https://www.mongodb.com/)** (3.6以上)
* **[Redis](https://redis.io/)**
##### オプション
* [Elasticsearch](https://www.elastic.co/) - 検索機能を向上させるために用います。
* [Redis](https://redis.io/)
* Redisはオプションですが、インストールすることを強く推奨します。
* インストールしなくていいのは、あなたのインスタンスが自分専用のときだけとお考えください。
* 具体的には、Redisをインストールしないと、次の事が出来なくなります:
* Misskeyプロセスを複数起動しての負荷分散
* レートリミット
* Twitter連携
* [Elasticsearch](https://www.elastic.co/)
* 検索機能を有効にするためにはインストールが必要です。
*3.* MongoDBの設定
----------------------------------------------------------------

View File

@ -34,7 +34,7 @@ common:
paragraph4: "Pour terminer la personnalisation, cliquez sur \"Terminer\" dans le coin supérieur droit."
gotit: "Compris !"
notification:
file-uploaded: "Le fichier a été téléversé !"
file-uploaded: "Le fichier a été transféré !"
message-from: "Message de {} :"
reversi-invited: "Invité à jouer"
reversi-invited-by: "Invité par {} :"
@ -136,7 +136,7 @@ common:
memo: "Pense-bête"
trends: "Tendances"
photo-stream: "Flux de photos"
posts-monitor: "Graphe des publications"
posts-monitor: "Graph des publications"
slideshow: "Diaporama"
version: "Version"
broadcast: "Diffusion"
@ -434,7 +434,7 @@ common/views/widgets/photo-stream.vue:
title: "Flux de photos"
no-photos: "Pas de photo"
common/views/widgets/posts-monitor.vue:
title: "Graphe des publications"
title: "Graph des publications"
toggle: "Basculer entre les vues"
common/views/widgets/hashtags.vue:
title: "Hashtags"
@ -582,7 +582,7 @@ desktop/views/components/drive.vue:
unable-to-process: "L'opération n'a pas pu être complétée"
circular-reference-detected: "Le dossier de destination est un sous-dossier du dossier que vous souhaitez déplacer."
unhandled-error: "Erreur inconnue"
url-upload: "Uploader d'un URL"
url-upload: "Téléverser via une URL"
url-of-file: "URL de l'image que vous souhaitez uploader."
url-upload-requested: "Upload requested"
may-take-time: "L'upload de votre fichier peut prendre un certain temps."
@ -590,8 +590,8 @@ desktop/views/components/drive.vue:
folder-name: "Nom du dossier"
contextmenu:
create-folder: "Créer un dossier"
upload: "Uploader un fichier"
url-upload: "Uploader d'un URL"
upload: "Transférer un fichier"
url-upload: "Transférer à partir dune URL"
desktop/views/components/media-image.vue:
sensitive: "Le contenu est NSFW"
click-to-show: "Cliquer pour afficher"
@ -658,21 +658,21 @@ desktop/views/components/post-form.vue:
add-visible-user: "+Ajouter un utilisateur"
attach-location-information: "Attacher des informations de localisation"
hide-contents: "Masquer les contenus"
reply-placeholder: "Répondre à cette note"
quote-placeholder: "Citer cette note"
submit: "Poster"
reply-placeholder: "Répondre à cette note"
quote-placeholder: "Citer cette note"
submit: "Publier"
reply: "Répondre"
renote: "Republier"
posted: "Posté!"
replied: "Répondu!"
reposted: "Reposté!"
posted: "Publié !"
replied: "Répondu !"
reposted: "Reposté !"
note-failed: "La note à échoué"
reply-failed: "La réponse à échoué"
renote-failed: "La renote à échoué"
posting: "Publication..."
attach-media-from-local: "Joindre un media depuis votre PC"
attach-media-from-drive: "Joindre un media depuis votre Drive"
attach-cancel: "Annuler la jointure de fichier"
renote-failed: "Échec lors de la republication"
posting: "Publication"
attach-media-from-local: "Joindre un média depuis votre appareil"
attach-media-from-drive: "Joindre un média depuis votre Drive"
attach-cancel: "Annuler le fichier attaché"
insert-a-kao: "v('ω')v"
create-poll: "Créer un sondage"
text-remain: "{} charactères restants"
@ -687,15 +687,15 @@ desktop/views/components/post-form-window.vue:
note: "Nouvelle note"
reply: "Répondre"
attaches: "{} media joint(s)"
uploading-media: "Upload du media {}"
uploading-media: "Transfert du média {}"
desktop/views/components/progress-dialog.vue:
waiting: "En attente"
desktop/views/components/renote-form.vue:
quote: "Citer..."
cancel: "Annuler"
renote: "Republier"
reposting: "Repost en cours..."
success: "Reposté!"
reposting: "Republication en cours"
success: "Republié !"
failure: "La renote a échoué"
desktop/views/components/renote-form-window.vue:
title: "Êtes vous sûr de vouloir renote cette note?"
@ -878,7 +878,7 @@ desktop/views/components/ui.header.nav.vue:
desktop/views/components/ui.header.notifications.vue:
title: "Notifications"
desktop/views/components/ui.header.post.vue:
post: "Composer un nouveau post"
post: "Rédiger une nouvelle publication"
desktop/views/components/ui.header.search.vue:
placeholder: "Chercher"
desktop/views/components/received-follow-requests-window.vue:
@ -969,7 +969,7 @@ desktop/views/pages/selectdrive.vue:
title: "Choisir fichier(s)"
ok: "OK"
cancel: "Annuler"
upload: "Uploader un ou plusieurs fichier(s) depuis votre PC"
upload: "Téléverser des fichiers à partir de votre ordinateur"
desktop/views/pages/search.vue:
not-available: "La fonction de recherche est désactivée dans les paramètres de linstance."
not-found: "Aucun message trouvé pour '{}'"
@ -1029,8 +1029,8 @@ desktop/views/widgets/polls.vue:
refresh: "Afficher d'autres"
nothing: "Rien"
desktop/views/widgets/post-form.vue:
title: "Post"
note: "Post"
title: "Publication"
note: "Publication"
desktop/views/widgets/profile.vue:
update-banner: "Cliquer pour éditer votre bannière"
update-avatar: "Cliquer pour éditer votre avatar"
@ -1092,7 +1092,7 @@ mobile/views/components/friends-maker.vue:
refresh: "Voir plus"
close: "Fermer"
mobile/views/components/note.vue:
reposted-by: "Renoté par {}"
reposted-by: "Republié par {}"
private: "cette publication est privée"
deleted: "cette publication a été supprimée"
location: "Géolocalisation"
@ -1119,7 +1119,7 @@ mobile/views/components/notifications.vue:
empty: "Pas de notifications"
mobile/views/components/post-form.vue:
add-visible-user: "Ajouter un utilisateur"
submit: "Poster"
submit: "Publier"
reply: "Répondre"
renote: "Republier"
quote-placeholder: "Citer ce billet ... (Facultatif)"

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "10.6.0",
"clientVersion": "1.0.10417",
"version": "10.10.0",
"clientVersion": "1.0.10466",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,
@ -60,7 +60,7 @@
"@types/mocha": "5.2.3",
"@types/mongodb": "3.1.12",
"@types/ms": "0.7.30",
"@types/node": "10.11.6",
"@types/node": "10.11.7",
"@types/portscanner": "2.1.0",
"@types/pug": "2.0.4",
"@types/qrcode": "1.3.0",
@ -169,6 +169,7 @@
"parse5": "5.1.0",
"portscanner": "2.2.0",
"progress-bar-webpack-plugin": "1.11.0",
"promise-limit": "2.7.0",
"promise-sequential": "1.1.1",
"pug": "2.0.3",
"punycode": "2.1.1",
@ -211,7 +212,7 @@
"v-animate-css": "0.0.2",
"vue": "2.5.17",
"vue-chartjs": "3.4.0",
"vue-color": "2.6.0",
"vue-color": "2.7.0",
"vue-cropperjs": "2.2.2",
"vue-js-modal": "1.3.26",
"vue-json-tree-view": "2.1.4",

View File

@ -0,0 +1,161 @@
import parse from '../../../../mfm/parse';
import { sum } from '../../../../prelude/array';
import MkNoteMenu from '..//views/components/note-menu.vue';
import MkReactionPicker from '../views/components/reaction-picker.vue';
function focus(el, fn) {
const target = fn(el);
if (target) {
if (target.hasAttribute('tabindex')) {
target.focus();
} else {
focus(target, fn);
}
}
}
type Opts = {
mobile?: boolean;
};
export default (opts: Opts = {}) => ({
data() {
return {
showContent: false
};
},
computed: {
keymap(): any {
return {
'r|left': () => this.reply(true),
'e|a|plus': () => this.react(true),
'q|right': () => this.renote(true),
'ctrl+q|ctrl+right': this.renoteDirectly,
'up|k|shift+tab': this.focusBefore,
'down|j|tab': this.focusAfter,
'esc': this.blur,
'm|o': () => this.menu(true),
's': this.toggleShowContent,
'1': () => this.reactDirectly('like'),
'2': () => this.reactDirectly('love'),
'3': () => this.reactDirectly('laugh'),
'4': () => this.reactDirectly('hmm'),
'5': () => this.reactDirectly('surprise'),
'6': () => this.reactDirectly('congrats'),
'7': () => this.reactDirectly('angry'),
'8': () => this.reactDirectly('confused'),
'9': () => this.reactDirectly('rip'),
'0': () => this.reactDirectly('pudding'),
};
},
isRenote(): boolean {
return (this.note.renote &&
this.note.text == null &&
this.note.fileIds.length == 0 &&
this.note.poll == null);
},
appearNote(): any {
return this.isRenote ? this.note.renote : this.note;
},
reactionsCount(): number {
return this.appearNote.reactionCounts
? sum(Object.values(this.appearNote.reactionCounts))
: 0;
},
title(): string {
return new Date(this.appearNote.createdAt).toLocaleString();
},
urls(): string[] {
if (this.appearNote.text) {
const ast = parse(this.appearNote.text);
return ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url);
} else {
return null;
}
}
},
methods: {
reply(viaKeyboard = false) {
(this as any).apis.post({
reply: this.appearNote,
animation: !viaKeyboard,
cb: () => {
this.focus();
}
});
},
renote(viaKeyboard = false) {
(this as any).apis.post({
renote: this.appearNote,
animation: !viaKeyboard,
cb: () => {
this.focus();
}
});
},
renoteDirectly() {
(this as any).api('notes/create', {
renoteId: this.appearNote.id
});
},
react(viaKeyboard = false) {
this.blur();
(this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton,
note: this.appearNote,
showFocus: viaKeyboard,
animation: !viaKeyboard,
compact: opts.mobile,
big: opts.mobile
}).$once('closed', this.focus);
},
reactDirectly(reaction) {
(this as any).api('notes/reactions/create', {
noteId: this.appearNote.id,
reaction: reaction
});
},
menu(viaKeyboard = false) {
(this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton,
note: this.appearNote,
animation: !viaKeyboard,
compact: opts.mobile,
}).$once('closed', this.focus);
},
toggleShowContent() {
this.showContent = !this.showContent;
},
focus() {
this.$el.focus();
},
blur() {
this.$el.blur();
},
focusBefore() {
focus(this.$el, e => e.previousElementSibling);
},
focusAfter() {
focus(this.$el, e => e.nextElementSibling);
}
}
});

View File

@ -10,7 +10,6 @@ import MiOS from '../../mios';
export default class Stream extends EventEmitter {
private stream: ReconnectingWebsocket;
private state: string;
private buffer: any[];
private sharedConnectionPools: Pool[] = [];
private sharedConnections: SharedConnection[] = [];
private nonSharedConnections: NonSharedConnection[] = [];
@ -19,7 +18,6 @@ export default class Stream extends EventEmitter {
super();
this.state = 'initializing';
this.buffer = [];
const user = os.store.state.i;
@ -29,7 +27,8 @@ export default class Stream extends EventEmitter {
this.stream.addEventListener('message', this.onMessage);
}
public useSharedConnection = (channel: string): SharedConnection => {
@autobind
public useSharedConnection(channel: string): SharedConnection {
let pool = this.sharedConnectionPools.find(p => p.channel === channel);
if (pool == null) {
@ -47,7 +46,13 @@ export default class Stream extends EventEmitter {
this.sharedConnections = this.sharedConnections.filter(c => c !== connection);
}
public connectToChannel = (channel: string, params?: any): NonSharedConnection => {
@autobind
public removeSharedConnectionPool(pool: Pool) {
this.sharedConnectionPools = this.sharedConnectionPools.filter(p => p !== pool);
}
@autobind
public connectToChannel(channel: string, params?: any): NonSharedConnection {
const connection = new NonSharedConnection(this, channel, params);
this.nonSharedConnections.push(connection);
return connection;
@ -68,13 +73,6 @@ export default class Stream extends EventEmitter {
this.state = 'connected';
this.emit('_connected_');
// バッファーを処理
const _buffer = [].concat(this.buffer); // Shallow copy
this.buffer = []; // Clear buffer
_buffer.forEach(data => {
this.send(data); // Resend each buffered messages
});
// チャンネル再接続
if (isReconnect) {
this.sharedConnectionPools.forEach(p => {
@ -91,8 +89,10 @@ export default class Stream extends EventEmitter {
*/
@autobind
private onClose() {
this.state = 'reconnecting';
this.emit('_disconnected_');
if (this.state == 'connected') {
this.state = 'reconnecting';
this.emit('_disconnected_');
}
}
/**
@ -131,12 +131,6 @@ export default class Stream extends EventEmitter {
body: payload
};
// まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する
if (this.state != 'connected') {
this.buffer.push(data);
return;
}
this.stream.send(JSON.stringify(data));
}
@ -154,7 +148,7 @@ class Pool {
public channel: string;
public id: string;
protected stream: Stream;
private users = 0;
public users = 0;
private disposeTimerId: any;
private isConnected = false;
@ -163,6 +157,13 @@ class Pool {
this.stream = stream;
this.id = Math.random().toString();
this.stream.on('_disconnected_', this.onStreamDisconnected);
}
@autobind
private onStreamDisconnected() {
this.isConnected = false;
}
@autobind
@ -196,6 +197,7 @@ class Pool {
@autobind
public connect() {
if (this.isConnected) return;
this.isConnected = true;
this.stream.send('connect', {
channel: this.channel,
@ -205,9 +207,9 @@ class Pool {
@autobind
private disconnect() {
this.isConnected = false;
this.disposeTimerId = null;
this.stream.off('_disconnected_', this.onStreamDisconnected);
this.stream.send('disconnect', { id: this.id });
this.stream.removeSharedConnectionPool(this);
}
}

View File

@ -6,13 +6,17 @@ export default (os: OS) => opts => {
const o = opts || {};
if (o.renote) {
const vm = os.new(RenoteFormWindow, {
note: o.renote
note: o.renote,
animation: o.animation == null ? true : o.animation
});
if (opts.cb) vm.$once('closed', opts.cb);
document.body.appendChild(vm.$el);
} else {
const vm = os.new(PostFormWindow, {
reply: o.reply
reply: o.reply,
animation: o.animation == null ? true : o.animation
});
if (opts.cb) vm.$once('closed', opts.cb);
document.body.appendChild(vm.$el);
}
};

View File

@ -1,7 +1,7 @@
<template>
<div class="note" tabindex="-1" v-hotkey="keymap" :title="title">
<div class="reply-to" v-if="p.reply && (!$store.getters.isSignedIn || $store.state.settings.showReplyTarget)">
<x-sub :note="p.reply"/>
<div class="note" v-show="appearNote.deletedAt == null" :tabindex="appearNote.deletedAt == null ? '-1' : null" v-hotkey="keymap" :title="title">
<div class="reply-to" v-if="appearNote.reply && (!$store.getters.isSignedIn || $store.state.settings.showReplyTarget)">
<x-sub :note="appearNote.reply"/>
</div>
<div class="renote" v-if="isRenote">
<mk-avatar class="avatar" :user="note.user"/>
@ -12,228 +12,76 @@
<mk-time :time="note.createdAt"/>
</div>
<article>
<mk-avatar class="avatar" :user="p.user"/>
<mk-avatar class="avatar" :user="appearNote.user"/>
<div class="main">
<mk-note-header class="header" :note="p"/>
<mk-note-header class="header" :note="appearNote"/>
<div class="body">
<p v-if="p.cw != null" class="cw">
<span class="text" v-if="p.cw != ''">{{ p.cw }}</span>
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="p.cw == null || showContent">
<div class="content" v-show="appearNote.cw == null || showContent">
<div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">%i18n:@private%</span>
<span v-if="p.deletedAt" style="opacity: 0.5">%i18n:@deleted%</span>
<a class="reply" v-if="p.reply">%fa:reply%</a>
<misskey-flavored-markdown v-if="p.text" :text="p.text" :i="$store.state.i" :class="$style.text"/>
<a class="rp" v-if="p.renote">RP:</a>
<span v-if="appearNote.isHidden" style="opacity: 0.5">%i18n:@private%</span>
<a class="reply" v-if="appearNote.reply">%fa:reply%</a>
<misskey-flavored-markdown v-if="appearNote.text" :text="appearNote.text" :i="$store.state.i" :class="$style.text"/>
<a class="rp" v-if="appearNote.renote">RP:</a>
</div>
<div class="files" v-if="p.files.length > 0">
<mk-media-list :media-list="p.files"/>
<div class="files" v-if="appearNote.files.length > 0">
<mk-media-list :media-list="appearNote.files"/>
</div>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<a class="location" v-if="p.geo" :href="`https://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% 位置情報</a>
<div class="map" v-if="p.geo" ref="map"></div>
<div class="renote" v-if="p.renote"><mk-note-preview :note="p.renote"/></div>
<mk-poll v-if="appearNote.poll" :note="appearNote" ref="pollViewer"/>
<a class="location" v-if="appearNote.geo" :href="`https://maps.google.com/maps?q=${appearNote.geo.coordinates[1]},${appearNote.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% 位置情報</a>
<div class="renote" v-if="appearNote.renote"><mk-note-preview :note="appearNote.renote"/></div>
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
</div>
</div>
<footer v-if="p.deletedAt == null">
<mk-reactions-viewer :note="p" ref="reactionsViewer"/>
<footer v-if="appearNote.deletedAt == null">
<mk-reactions-viewer :note="appearNote" ref="reactionsViewer"/>
<button class="replyButton" @click="reply()" title="%i18n:@reply%">
<template v-if="p.reply">%fa:reply-all%</template>
<template v-if="appearNote.reply">%fa:reply-all%</template>
<template v-else>%fa:reply%</template>
<p class="count" v-if="p.repliesCount > 0">{{ p.repliesCount }}</p>
<p class="count" v-if="appearNote.repliesCount > 0">{{ appearNote.repliesCount }}</p>
</button>
<button class="renoteButton" @click="renote()" title="%i18n:@renote%">
%fa:retweet%<p class="count" v-if="p.renoteCount > 0">{{ p.renoteCount }}</p>
%fa:retweet%<p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p>
</button>
<button class="reactionButton" :class="{ reacted: p.myReaction != null }" @click="react()" ref="reactButton" title="%i18n:@add-reaction%">
%fa:plus%<p class="count" v-if="p.reactions_count > 0">{{ p.reactions_count }}</p>
<button class="reactionButton" :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton" title="%i18n:@add-reaction%">
%fa:plus%<p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
</button>
<button @click="menu()" ref="menuButton">
%fa:ellipsis-h%
</button>
<!-- <button title="%i18n:@detail">
<template v-if="!isDetailOpened">%fa:caret-down%</template>
<template v-if="isDetailOpened">%fa:caret-up%</template>
</button> -->
</footer>
</div>
</article>
<div class="detail" v-if="isDetailOpened">
<mk-note-status-graph width="462" height="130" :note="p"/>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import parse from '../../../../../mfm/parse';
import MkPostFormWindow from './post-form-window.vue';
import MkRenoteFormWindow from './renote-form-window.vue';
import MkNoteMenu from '../../../common/views/components/note-menu.vue';
import MkReactionPicker from '../../../common/views/components/reaction-picker.vue';
import XSub from './notes.note.sub.vue';
import { sum } from '../../../../../prelude/array';
import noteMixin from '../../../common/scripts/note-mixin';
import noteSubscriber from '../../../common/scripts/note-subscriber';
function focus(el, fn) {
const target = fn(el);
if (target) {
if (target.hasAttribute('tabindex')) {
target.focus();
} else {
focus(target, fn);
}
}
}
export default Vue.extend({
components: {
XSub
},
mixins: [noteSubscriber('note')],
mixins: [
noteMixin(),
noteSubscriber('note')
],
props: {
note: {
type: Object,
required: true
}
},
data() {
return {
showContent: false,
isDetailOpened: false
};
},
computed: {
keymap(): any {
return {
'r|left': () => this.reply(true),
'e|a|plus': () => this.react(true),
'q|right': () => this.renote(true),
'ctrl+q|ctrl+right': this.renoteDirectly,
'up|k|shift+tab': this.focusBefore,
'down|j|tab': this.focusAfter,
'esc': this.blur,
'm|o': () => this.menu(true),
's': this.toggleShowContent,
'1': () => this.reactDirectly('like'),
'2': () => this.reactDirectly('love'),
'3': () => this.reactDirectly('laugh'),
'4': () => this.reactDirectly('hmm'),
'5': () => this.reactDirectly('surprise'),
'6': () => this.reactDirectly('congrats'),
'7': () => this.reactDirectly('angry'),
'8': () => this.reactDirectly('confused'),
'9': () => this.reactDirectly('rip'),
'0': () => this.reactDirectly('pudding'),
};
},
isRenote(): boolean {
return (this.note.renote &&
this.note.text == null &&
this.note.fileIds.length == 0 &&
this.note.poll == null);
},
p(): any {
return this.isRenote ? this.note.renote : this.note;
},
reactionsCount(): number {
return this.p.reactionCounts
? sum(Object.values(this.p.reactionCounts))
: 0;
},
title(): string {
return new Date(this.p.createdAt).toLocaleString();
},
urls(): string[] {
if (this.p.text) {
const ast = parse(this.p.text);
return ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url);
} else {
return null;
}
}
},
methods: {
reply(viaKeyboard = false) {
(this as any).os.new(MkPostFormWindow, {
reply: this.p,
animation: !viaKeyboard
}).$once('closed', this.focus);
},
renote(viaKeyboard = false) {
(this as any).os.new(MkRenoteFormWindow, {
note: this.p,
animation: !viaKeyboard
}).$once('closed', this.focus);
},
renoteDirectly() {
(this as any).api('notes/create', {
renoteId: this.p.id
});
},
react(viaKeyboard = false) {
this.blur();
(this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton,
note: this.p,
showFocus: viaKeyboard,
animation: !viaKeyboard
}).$once('closed', this.focus);
},
reactDirectly(reaction) {
(this as any).api('notes/reactions/create', {
noteId: this.p.id,
reaction: reaction
});
},
menu(viaKeyboard = false) {
(this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton,
note: this.p,
animation: !viaKeyboard
}).$once('closed', this.focus);
},
toggleShowContent() {
this.showContent = !this.showContent;
},
focus() {
this.$el.focus();
},
blur() {
this.$el.blur();
},
focusBefore() {
focus(this.$el, e => e.previousElementSibling);
},
focusAfter() {
focus(this.$el, e => e.nextElementSibling);
}
}
});
</script>
@ -445,10 +293,6 @@ export default Vue.extend({
&.reacted, &.reacted:hover
color var(--noteActionsReactionHover)
> .detail
padding-top 4px
background rgba(#000, 0.0125)
</style>
<style lang="stylus" module>

View File

@ -310,7 +310,7 @@ export default Vue.extend({
> header
display flex
z-index 1
z-index 2
line-height $header-height
padding 0 16px
font-size 14px

View File

@ -1,7 +1,15 @@
<template>
<div v-if="!mediaView" class="zyjjkidcqjnlegkqebitfviomuqmseqk" :class="{ renote: isRenote }">
<div class="reply-to" v-if="p.reply && (!$store.getters.isSignedIn || $store.state.settings.showReplyTarget)">
<x-sub :note="p.reply"/>
<div
v-if="!mediaView"
v-show="appearNote.deletedAt == null"
:tabindex="appearNote.deletedAt == null ? '-1' : null"
class="zyjjkidcqjnlegkqebitfviomuqmseqk"
:class="{ renote: isRenote }"
v-hotkey="keymap"
:title="title"
>
<div class="reply-to" v-if="appearNote.reply && (!$store.getters.isSignedIn || $store.state.settings.showReplyTarget)">
<x-sub :note="appearNote.reply"/>
</div>
<div class="renote" v-if="isRenote">
<mk-avatar class="avatar" :user="note.user"/>
@ -12,43 +20,42 @@
<mk-time :time="note.createdAt"/>
</div>
<article>
<mk-avatar class="avatar" :user="p.user"/>
<mk-avatar class="avatar" :user="appearNote.user"/>
<div class="main">
<mk-note-header class="header" :note="p" :mini="true"/>
<mk-note-header class="header" :note="appearNote" :mini="true"/>
<div class="body">
<p v-if="p.cw != null" class="cw">
<span class="text" v-if="p.cw != ''">{{ p.cw }}</span>
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="p.cw == null || showContent">
<div class="content" v-show="appearNote.cw == null || showContent">
<div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">(%i18n:@private%)</span>
<span v-if="p.deletedAt" style="opacity: 0.5">(%i18n:@deleted%)</span>
<a class="reply" v-if="p.reply">%fa:reply%</a>
<misskey-flavored-markdown v-if="p.text" :text="p.text" :i="$store.state.i"/>
<a class="rp" v-if="p.renote != null">RP:</a>
<span v-if="appearNote.isHidden" style="opacity: 0.5">(%i18n:@private%)</span>
<a class="reply" v-if="appearNote.reply">%fa:reply%</a>
<misskey-flavored-markdown v-if="appearNote.text" :text="appearNote.text" :i="$store.state.i"/>
<a class="rp" v-if="appearNote.renote != null">RP:</a>
</div>
<div class="files" v-if="p.files.length > 0">
<mk-media-list :media-list="p.files"/>
<div class="files" v-if="appearNote.files.length > 0">
<mk-media-list :media-list="appearNote.files"/>
</div>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<a class="location" v-if="p.geo" :href="`https://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>
<div class="renote" v-if="p.renote">
<mk-note-preview :note="p.renote" :mini="true"/>
<mk-poll v-if="appearNote.poll" :note="appearNote" ref="pollViewer"/>
<a class="location" v-if="appearNote.geo" :href="`https://maps.google.com/maps?q=${appearNote.geo.coordinates[1]},${appearNote.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>
<div class="renote" v-if="appearNote.renote">
<mk-note-preview :note="appearNote.renote" :mini="true"/>
</div>
<mk-url-preview v-for="url in urls" :url="url" :key="url" :detail="false" :mini="true"/>
</div>
<span class="app" v-if="p.app">via <b>{{ p.app.name }}</b></span>
<span class="app" v-if="appearNote.app">via <b>{{ appearNote.app.name }}</b></span>
</div>
<footer>
<mk-reactions-viewer :note="p" ref="reactionsViewer"/>
<button @click="reply">
<template v-if="p.reply">%fa:reply-all%</template>
<mk-reactions-viewer :note="appearNote" ref="reactionsViewer"/>
<button @click="reply()">
<template v-if="appearNote.reply">%fa:reply-all%</template>
<template v-else>%fa:reply%</template>
</button>
<button @click="renote" title="Renote">%fa:retweet%</button>
<button :class="{ reacted: p.myReaction != null }" @click="react" ref="reactButton">%fa:plus%</button>
<button class="menu" @click="menu" ref="menuButton">%fa:ellipsis-h%</button>
<button @click="renote()" title="Renote">%fa:retweet%</button>
<button :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton">%fa:plus%</button>
<button class="menu" @click="menu()" ref="menuButton">%fa:ellipsis-h%</button>
</footer>
</div>
</article>
@ -65,11 +72,10 @@
<script lang="ts">
import Vue from 'vue';
import parse from '../../../../../../mfm/parse';
import MkNoteMenu from '../../../../common/views/components/note-menu.vue';
import MkReactionPicker from '../../../../common/views/components/reaction-picker.vue';
import MkPostFormWindow from '../../components/post-form-window.vue';
import MkRenoteFormWindow from '../../components/renote-form-window.vue';
import XSub from './deck.note.sub.vue';
import noteMixin from '../../../../common/scripts/note-mixin';
import noteSubscriber from '../../../../common/scripts/note-subscriber';
export default Vue.extend({
@ -77,7 +83,10 @@ export default Vue.extend({
XSub
},
mixins: [noteSubscriber('note')],
mixins: [
noteMixin(),
noteSubscriber('note')
],
props: {
note: {
@ -89,66 +98,6 @@ export default Vue.extend({
required: false,
default: false
}
},
data() {
return {
showContent: false
};
},
computed: {
isRenote(): boolean {
return (this.note.renote &&
this.note.text == null &&
this.note.fileIds.length == 0 &&
this.note.poll == null);
},
p(): any {
return this.isRenote ? this.note.renote : this.note;
},
urls(): string[] {
if (this.p.text) {
const ast = parse(this.p.text);
return ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url);
} else {
return null;
}
}
},
methods: {
reply() {
(this as any).apis.post({
reply: this.p
});
},
renote() {
(this as any).apis.post({
renote: this.p
});
},
react() {
(this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton,
note: this.p,
compact: true
});
},
menu() {
(this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton,
note: this.p,
compact: true
});
}
}
});
</script>
@ -168,6 +117,20 @@ export default Vue.extend({
font-size 13px
border-bottom solid 1px var(--faceDivider)
&:focus
z-index 1
&:after
content ""
pointer-events none
position absolute
top 2px
right 2px
bottom 2px
left 2px
border 2px solid var(--primaryAlpha03)
border-radius 4px
&:last-of-type
border-bottom none

View File

@ -18,6 +18,7 @@ export default (os) => (opts) => {
}).$mount();
vm.$once('cancel', recover);
vm.$once('posted', recover);
if (opts.cb) vm.$once('closed', opts.cb);
document.body.appendChild(vm.$el);
(vm as any).focus();
};

View File

@ -1,7 +1,13 @@
<template>
<div class="note" :class="{ renote: isRenote, smart: $store.state.device.postStyle == 'smart' }">
<div class="reply-to" v-if="p.reply && (!$store.getters.isSignedIn || $store.state.settings.showReplyTarget)">
<x-sub :note="p.reply"/>
<div
class="note"
v-show="appearNote.deletedAt == null"
:tabindex="appearNote.deletedAt == null ? '-1' : null"
:class="{ renote: isRenote, smart: $store.state.device.postStyle == 'smart' }"
v-hotkey="keymap"
>
<div class="reply-to" v-if="appearNote.reply && (!$store.getters.isSignedIn || $store.state.settings.showReplyTarget)">
<x-sub :note="appearNote.reply"/>
</div>
<div class="renote" v-if="isRenote">
<mk-avatar class="avatar" :user="note.user"/>
@ -12,47 +18,45 @@
<mk-time :time="note.createdAt"/>
</div>
<article>
<mk-avatar class="avatar" :user="p.user" v-if="$store.state.device.postStyle != 'smart'"/>
<mk-avatar class="avatar" :user="appearNote.user" v-if="$store.state.device.postStyle != 'smart'"/>
<div class="main">
<mk-note-header class="header" :note="p" :mini="true"/>
<mk-note-header class="header" :note="appearNote" :mini="true"/>
<div class="body">
<p v-if="p.cw != null" class="cw">
<span class="text" v-if="p.cw != ''">{{ p.cw }}</span>
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="p.cw == null || showContent">
<div class="content" v-show="appearNote.cw == null || showContent">
<div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">(%i18n:@private%)</span>
<span v-if="p.deletedAt" style="opacity: 0.5">(%i18n:@deleted%)</span>
<a class="reply" v-if="p.reply">%fa:reply%</a>
<misskey-flavored-markdown v-if="p.text" :text="p.text" :i="$store.state.i" :class="$style.text"/>
<a class="rp" v-if="p.renote != null">RP:</a>
<span v-if="appearNote.isHidden" style="opacity: 0.5">(%i18n:@private%)</span>
<a class="reply" v-if="appearNote.reply">%fa:reply%</a>
<misskey-flavored-markdown v-if="appearNote.text" :text="appearNote.text" :i="$store.state.i" :class="$style.text"/>
<a class="rp" v-if="appearNote.renote != null">RP:</a>
</div>
<div class="files" v-if="p.files.length > 0">
<mk-media-list :media-list="p.files"/>
<div class="files" v-if="appearNote.files.length > 0">
<mk-media-list :media-list="appearNote.files"/>
</div>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<mk-poll v-if="appearNote.poll" :note="appearNote" ref="pollViewer"/>
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
<a class="location" v-if="p.geo" :href="`https://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>
<div class="map" v-if="p.geo" ref="map"></div>
<div class="renote" v-if="p.renote"><mk-note-preview :note="p.renote"/></div>
<a class="location" v-if="appearNote.geo" :href="`https://maps.google.com/maps?q=${appearNote.geo.coordinates[1]},${appearNote.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>
<div class="renote" v-if="appearNote.renote"><mk-note-preview :note="appearNote.renote"/></div>
</div>
<span class="app" v-if="p.app">via <b>{{ p.app.name }}</b></span>
<span class="app" v-if="appearNote.app">via <b>{{ appearNote.apappearNote.name }}</b></span>
</div>
<footer v-if="p.deletedAt == null">
<mk-reactions-viewer :note="p" ref="reactionsViewer"/>
<button @click="reply">
<template v-if="p.reply">%fa:reply-all%</template>
<footer v-if="appearNote.deletedAt == null">
<mk-reactions-viewer :note="appearNote" ref="reactionsViewer"/>
<button @click="reply()">
<template v-if="appearNote.reply">%fa:reply-all%</template>
<template v-else>%fa:reply%</template>
<p class="count" v-if="p.repliesCount > 0">{{ p.repliesCount }}</p>
<p class="count" v-if="appearNote.repliesCount > 0">{{ appearNote.repliesCount }}</p>
</button>
<button @click="renote" title="Renote">
%fa:retweet%<p class="count" v-if="p.renoteCount > 0">{{ p.renoteCount }}</p>
<button @click="renote()" title="Renote">
%fa:retweet%<p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p>
</button>
<button :class="{ reacted: p.myReaction != null }" @click="react" ref="reactButton">
%fa:plus%<p class="count" v-if="p.reactions_count > 0">{{ p.reactions_count }}</p>
<button :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton">
%fa:plus%<p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
</button>
<button class="menu" @click="menu" ref="menuButton">
<button class="menu" @click="menu()" ref="menuButton">
%fa:ellipsis-h%
</button>
</footer>
@ -63,12 +67,9 @@
<script lang="ts">
import Vue from 'vue';
import parse from '../../../../../mfm/parse';
import MkNoteMenu from '../../../common/views/components/note-menu.vue';
import MkReactionPicker from '../../../common/views/components/reaction-picker.vue';
import XSub from './note.sub.vue';
import { sum } from '../../../../../prelude/array';
import noteMixin from '../../../common/scripts/note-mixin';
import noteSubscriber from '../../../common/scripts/note-subscriber';
export default Vue.extend({
@ -76,74 +77,17 @@ export default Vue.extend({
XSub
},
mixins: [noteSubscriber('note')],
mixins: [
noteMixin({
mobile: true
}),
noteSubscriber('note')
],
props: ['note'],
data() {
return {
showContent: false
};
},
computed: {
isRenote(): boolean {
return (this.note.renote &&
this.note.text == null &&
this.note.fileIds.length == 0 &&
this.note.poll == null);
},
p(): any {
return this.isRenote ? this.note.renote : this.note;
},
reactionsCount(): number {
return this.p.reactionCounts
? sum(Object.values(this.p.reactionCounts))
: 0;
},
urls(): string[] {
if (this.p.text) {
const ast = parse(this.p.text);
return ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url);
} else {
return null;
}
}
},
methods: {
reply() {
(this as any).apis.post({
reply: this.p
});
},
renote() {
(this as any).apis.post({
renote: this.p
});
},
react() {
(this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton,
note: this.p,
compact: true,
big: true
});
},
menu() {
(this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton,
note: this.p,
compact: true
});
props: {
note: {
type: Object,
required: true
}
}
});
@ -154,6 +98,20 @@ export default Vue.extend({
font-size 12px
border-bottom solid 1px var(--faceDivider)
&:focus
z-index 1
&:after
content ""
pointer-events none
position absolute
top 2px
right 2px
bottom 2px
left 2px
border 2px solid var(--primaryAlpha03)
border-radius 4px
&:last-of-type
border-bottom none

View File

@ -93,11 +93,9 @@ export type Source = {
private_key: string;
};
google_maps_api_key: string;
clusterLimit?: number;
user_recommendation: {
user_recommendation?: {
external: boolean;
engine: string;
timeout: number;

View File

@ -1,10 +1,10 @@
import * as redis from 'redis';
import config from '../config';
export default redis.createClient(
export default config.redis ? redis.createClient(
config.redis.port,
config.redis.host,
{
auth_pass: config.redis.pass
}
);
) : null;

View File

@ -166,7 +166,7 @@ export const pack = (
// (データベースの欠損などで)ファイルがデータベース上に見つからなかったとき
if (_file == null) {
console.warn(`in packaging driveFile: driveFile not found on database: ${_file}`);
console.warn(`[DAMAGED DB] (missing) pkg: driveFile :: ${file}`);
return resolve(null);
}

View File

@ -79,7 +79,7 @@ export const pack = (
// (データベースの不具合などで)投稿が見つからなかったら
if (_favorite.note == null) {
console.warn(`in packaging favorite: note not found on database: ${_favorite.noteId}`);
console.warn(`[DAMAGED DB] (missing) pkg: favorite -> note :: ${_favorite.id} (note ${_favorite.noteId})`);
return resolve(null);
}

View File

@ -281,9 +281,9 @@ export const pack = async (
_note = deepcopy(note);
}
// 投稿がデータベース上に見つからなかったとき
// (データベースの欠損などで)投稿がデータベース上に見つからなかったとき
if (_note == null) {
console.warn(`note not found on database: ${note}`);
console.warn(`[DAMAGED DB] (missing) pkg: note :: ${note}`);
return null;
}
@ -380,12 +380,25 @@ export const pack = async (
// resolve promises in _note object
_note = await rap(_note);
// (データベースの欠損などで)ユーザーがデータベース上に見つからなかったとき
//#region (データベースの欠損などで)参照しているデータがデータベース上に見つからなかったとき
if (_note.user == null) {
console.warn(`in packaging note: note user not found on database: note(${_note.id})`);
console.warn(`[DAMAGED DB] (missing) pkg: note -> user :: ${_note.id} (user ${_note.userId})`);
return null;
}
if (opts.detail) {
if (_note.replyId != null && _note.reply == null) {
console.warn(`[DAMAGED DB] (missing) pkg: note -> reply :: ${_note.id} (reply ${_note.replyId})`);
return null;
}
if (_note.renoteId != null && _note.renote == null) {
console.warn(`[DAMAGED DB] (missing) pkg: note -> renote :: ${_note.id} (renote ${_note.renoteId})`);
return null;
}
}
//#endregion
if (_note.user.isCat && _note.text) {
_note.text = _note.text.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ');
}

View File

@ -132,7 +132,7 @@ export const pack = (notification: any) => new Promise<any>(async (resolve, reje
// (データベースの不具合などで)投稿が見つからなかったら
if (_notification.note == null) {
console.warn(`in packaging notification: note not found on database: ${_notification.noteId}`);
console.warn(`[DAMAGED DB] (missing) pkg: notification -> note :: ${_notification.id} (note ${_notification.noteId})`);
return resolve(null);
}
break;

View File

@ -27,7 +27,8 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
const file = await DriveFile.findOne({
md5: md5,
'metadata.userId': user._id
'metadata.userId': user._id,
'metadata.deletedAt': { $exists: false }
});
if (file === null) {

View File

@ -22,7 +22,8 @@ export default async (params: any, user: ILocalUser) => {
const file = await DriveFile
.findOne({
_id: fileId,
'metadata.userId': user._id
'metadata.userId': user._id,
'metadata.deletedAt': { $exists: false }
});
if (file === null) {

View File

@ -58,6 +58,8 @@ export default async (params: any, user: ILocalUser) => {
};
const query = {
deletedAt: null,
// public only
visibility: 'public',

View File

@ -129,6 +129,8 @@ export default async (params: any, user: ILocalUser) => {
const query = {
$and: [{
deletedAt: null,
$or: [{
// フォローしている人の投稿
$or: followQuery

View File

@ -71,6 +71,8 @@ export default async (params: any, user: ILocalUser) => {
};
const query = {
deletedAt: null,
// public only
visibility: 'public',

View File

@ -45,6 +45,8 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
// Construct query
const query = {
deletedAt: null,
$or: [{
mentions: user._id
}, {

View File

@ -132,6 +132,8 @@ export default async (params: any, user: ILocalUser) => {
const query = {
$and: [{
deletedAt: null,
// フォローしている人の投稿
$or: followQuery,

View File

@ -137,6 +137,8 @@ export default async (params: any, user: ILocalUser) => {
const query = {
$and: [{
deletedAt: null,
// リストに入っている人のタイムラインへの投稿
$or: listQuery,

View File

@ -136,6 +136,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
};
const query = {
deletedAt: null,
userId: user._id
} as any;

View File

@ -69,13 +69,10 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
$nin: followingIds.concat(mutedUserIds)
},
isLocked: { $ne: true },
$or: [{
lastUsedAt: {
$gte: new Date(Date.now() - ms('7days'))
}
}, {
host: null
}]
lastUsedAt: {
$gte: new Date(Date.now() - ms('7days'))
},
host: null
}, {
limit: limit,
skip: offset,

View File

@ -8,6 +8,12 @@ import { IUser } from '../../models/user';
const log = debug('misskey:limitter');
export default (endpoint: IEndpoint, user: IUser) => new Promise((ok, reject) => {
// Redisがインストールされてない場合は常に許可
if (limiterDB == null) {
ok();
return;
}
const limitation = endpoint.meta.limit;
const key = limitation.hasOwnProperty('key')

View File

@ -55,7 +55,7 @@ router.get('/disconnect/twitter', async ctx => {
}));
});
if (config.twitter == null) {
if (config.twitter == null || redis == null) {
router.get('/connect/twitter', ctx => {
ctx.body = '現在Twitterへ接続できません (このインスタンスではTwitterはサポートされていません)';
});

View File

@ -7,6 +7,8 @@ import Connection from '.';
export default abstract class Channel {
protected connection: Connection;
public id: string;
public abstract readonly chName: string;
public static readonly shouldShare: boolean;
protected get user() {
return this.connection.user;

View File

@ -2,6 +2,9 @@ import autobind from 'autobind-decorator';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'drive';
public static shouldShare = true;
@autobind
public async init(params: any) {
// Subscribe drive stream

View File

@ -1,5 +1,6 @@
import autobind from 'autobind-decorator';
import * as CRC32 from 'crc-32';
import * as mongo from 'mongodb';
import ReversiGame, { pack } from '../../../../../models/games/reversi/game';
import { publishReversiGameStream } from '../../../../../stream';
import Reversi from '../../../../../games/reversi/core';
@ -7,11 +8,14 @@ import * as maps from '../../../../../games/reversi/maps';
import Channel from '../../channel';
export default class extends Channel {
private gameId: string;
public readonly chName = 'gamesReversiGame';
public static shouldShare = false;
private gameId: mongo.ObjectID;
@autobind
public async init(params: any) {
this.gameId = params.gameId as string;
this.gameId = new mongo.ObjectID(params.gameId as string);
// Subscribe game stream
this.subscriber.on(`reversiGameStream:${this.gameId}`, data => {

View File

@ -5,6 +5,9 @@ import { publishMainStream } from '../../../../../stream';
import Channel from '../../channel';
export default class extends Channel {
public readonly chName = 'gamesReversi';
public static shouldShare = true;
@autobind
public async init(params: any) {
// Subscribe reversi stream

View File

@ -5,6 +5,9 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'globalTimeline';
public static shouldShare = true;
private mutedUserIds: string[] = [];
@autobind

View File

@ -5,6 +5,9 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'hashtag';
public static shouldShare = false;
@autobind
public async init(params: any) {
const mute = this.user ? await Mute.find({ muterId: this.user._id }) : null;

View File

@ -5,6 +5,9 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'homeTimeline';
public static shouldShare = true;
private mutedUserIds: string[] = [];
@autobind

View File

@ -5,6 +5,9 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'hybridTimeline';
public static shouldShare = true;
private mutedUserIds: string[] = [];
@autobind

View File

@ -5,6 +5,9 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'localTimeline';
public static shouldShare = true;
private mutedUserIds: string[] = [];
@autobind

View File

@ -3,6 +3,9 @@ import Mute from '../../../../models/mute';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'main';
public static shouldShare = true;
@autobind
public async init(params: any) {
const mute = await Mute.find({ muterId: this.user._id });

View File

@ -2,6 +2,9 @@ import autobind from 'autobind-decorator';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'messagingIndex';
public static shouldShare = true;
@autobind
public async init(params: any) {
// Subscribe messaging index stream

View File

@ -3,6 +3,9 @@ import read from '../../common/read-messaging-message';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'messaging';
public static shouldShare = false;
private otherpartyId: string;
@autobind

View File

@ -5,6 +5,9 @@ import Channel from '../channel';
const ev = new Xev();
export default class extends Channel {
public readonly chName = 'notesStats';
public static shouldShare = true;
@autobind
public async init(params: any) {
ev.addListener('notesStats', this.onStats);

View File

@ -5,6 +5,9 @@ import Channel from '../channel';
const ev = new Xev();
export default class extends Channel {
public readonly chName = 'serverStats';
public static shouldShare = true;
@autobind
public async init(params: any) {
ev.addListener('serverStats', this.onStats);

View File

@ -2,6 +2,9 @@ import autobind from 'autobind-decorator';
import Channel from '../channel';
export default class extends Channel {
public readonly chName = 'userList';
public static shouldShare = false;
@autobind
public async init(params: any) {
const listId = params.listId as string;

View File

@ -1,6 +1,5 @@
import autobind from 'autobind-decorator';
import * as websocket from 'websocket';
import Xev from 'xev';
import * as debug from 'debug';
import User, { IUser } from '../../../models/user';
@ -11,6 +10,7 @@ import readNote from '../../../services/note/read';
import Channel from './channel';
import channels from './channels';
import { EventEmitter } from 'events';
const log = debug('misskey');
@ -21,14 +21,14 @@ export default class Connection {
public user?: IUser;
public app: IApp;
private wsConnection: websocket.connection;
public subscriber: Xev;
public subscriber: EventEmitter;
private channels: Channel[] = [];
private subscribingNotes: any = {};
public sendMessageToWsOverride: any = null; // 後方互換性のため
constructor(
wsConnection: websocket.connection,
subscriber: Xev,
subscriber: EventEmitter,
user: IUser,
app: IApp
) {
@ -148,7 +148,7 @@ export default class Connection {
private onChannelConnectRequested(payload: any) {
const { channel, id, params } = payload;
log(`CH CONNECT: ${id} ${channel} by @${this.user.username}`);
this.connectChannel(id, params, (channels as any)[channel]);
this.connectChannel(id, params, channel);
}
/**
@ -177,10 +177,15 @@ export default class Connection {
* チャンネルに接続
*/
@autobind
public connectChannel(id: string, params: any, channelClass: { new(id: string, connection: Connection): Channel }) {
const channel = new channelClass(id, this);
this.channels.push(channel);
channel.init(params);
public connectChannel(id: string, params: any, channel: string) {
// 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視
if ((channels as any)[channel].shouldShare && this.channels.some(c => c.chName === channel)) {
return;
}
const ch: Channel = new (channels as any)[channel](id, this);
this.channels.push(ch);
ch.init(params);
this.sendMessageToWs('connected', {
id: id
});

View File

@ -1,11 +1,13 @@
import * as http from 'http';
import * as websocket from 'websocket';
import * as redis from 'redis';
import Xev from 'xev';
import MainStreamConnection from './stream';
import { ParsedUrlQuery } from 'querystring';
import authenticate from './authenticate';
import channels from './stream/channels';
import { EventEmitter } from 'events';
import config from '../../config';
module.exports = (server: http.Server) => {
// Init websocket server
@ -16,11 +18,34 @@ module.exports = (server: http.Server) => {
ws.on('request', async (request) => {
const connection = request.accept();
const ev = new Xev();
const q = request.resourceURL.query as ParsedUrlQuery;
const [user, app] = await authenticate(q.i as string);
let ev: EventEmitter;
if (config.redis) {
// Connect to Redis
const subscriber = redis.createClient(
config.redis.port, config.redis.host);
subscriber.subscribe('misskey');
ev = new EventEmitter();
subscriber.on('message', async (_, data) => {
const obj = JSON.parse(data);
ev.emit(obj.channel, obj.message);
});
connection.once('close', () => {
subscriber.unsubscribe();
subscriber.quit();
});
} else {
ev = new Xev();
}
const main = new MainStreamConnection(connection, ev, user, app);
// 後方互換性のため
@ -40,13 +65,13 @@ module.exports = (server: http.Server) => {
};
main.connectChannel(Math.random().toString(), null,
request.resourceURL.pathname === '/' ? channels.homeTimeline :
request.resourceURL.pathname === '/local-timeline' ? channels.localTimeline :
request.resourceURL.pathname === '/hybrid-timeline' ? channels.hybridTimeline :
request.resourceURL.pathname === '/global-timeline' ? channels.globalTimeline : null);
request.resourceURL.pathname === '/' ? 'homeTimeline' :
request.resourceURL.pathname === '/local-timeline' ? 'localTimeline' :
request.resourceURL.pathname === '/hybrid-timeline' ? 'hybridTimeline' :
request.resourceURL.pathname === '/global-timeline' ? 'globalTimeline' : null);
if (request.resourceURL.pathname === '/') {
main.connectChannel(Math.random().toString(), null, channels.main);
main.connectChannel(Math.random().toString(), null, 'main');
}
}

View File

@ -1,4 +1,5 @@
import * as mongo from 'mongodb';
import redis from './db/redis';
import Xev from 'xev';
import Meta, { IMeta } from './models/meta';
@ -9,7 +10,10 @@ class Publisher {
private meta: IMeta;
constructor() {
this.ev = new Xev();
// Redisがインストールされてないときはプロセス間通信を使う
if (redis == null) {
this.ev = new Xev();
}
setInterval(async () => {
this.meta = await Meta.findOne({});
@ -28,7 +32,14 @@ class Publisher {
{ type: type, body: null } :
{ type: type, body: value };
this.ev.emit(channel, message);
if (this.ev) {
this.ev.emit(channel, message);
} else {
redis.publish('misskey', JSON.stringify({
channel: channel,
message: message
}));
}
}
public publishMainStream = (userId: ID, type: string, value?: any): void => {

View File

@ -1,67 +1,83 @@
import * as Minio from 'minio';
import * as uuid from 'uuid';
const sequential = require('promise-sequential');
import DriveFile, { DriveFileChunk, getDriveFileBucket } from '../models/drive-file';
import * as promiseLimit from 'promise-limit';
import DriveFile, { DriveFileChunk, getDriveFileBucket, IDriveFile } from '../models/drive-file';
import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../models/drive-file-thumbnail';
import config from '../config';
const limit = promiseLimit(16);
DriveFile.find({
$or: [{
withoutChunks: { $exists: false }
'metadata.withoutChunks': { $exists: false }
}, {
withoutChunks: false
}]
'metadata.withoutChunks': false
}],
'metadata.deletedAt': { $exists: false }
}, {
fields: {
_id: true
}
}).then(async files => {
await sequential(files.map(file => async () => {
const minio = new Minio.Client(config.drive.config);
console.log(`there is ${files.length} files`);
const keyDir = `${config.drive.prefix}/${uuid.v4()}`;
const key = `${keyDir}/${name}`;
const thumbnailKeyDir = `${config.drive.prefix}/${uuid.v4()}`;
const thumbnailKey = `${thumbnailKeyDir}/${name}.thumbnail.jpg`;
await Promise.all(files.map(file => limit(() => job(file))));
const baseUrl = config.drive.baseUrl
|| `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? `:${config.drive.config.port}` : '' }/${ config.drive.bucket }`;
const bucket = await getDriveFileBucket();
const readable = bucket.openDownloadStream(file._id);
await minio.putObject(config.drive.bucket, key, readable, file.length, {
'Content-Type': file.contentType,
'Cache-Control': 'max-age=31536000, immutable'
});
await DriveFile.findOneAndUpdate({ _id: file._id }, {
$set: {
'metadata.withoutChunks': true,
'metadata.storage': 'minio',
'metadata.storageProps': {
key: key,
thumbnailKey: thumbnailKey
},
'metadata.url': `${ baseUrl }/${ keyDir }/${ encodeURIComponent(name) }`,
}
});
// チャンクをすべて削除
await DriveFileChunk.remove({
files_id: file._id
});
//#region サムネイルもあれば削除
const thumbnail = await DriveFileThumbnail.findOne({
'metadata.originalId': file._id
});
if (thumbnail) {
await DriveFileThumbnailChunk.remove({
files_id: thumbnail._id
});
await DriveFileThumbnail.remove({ _id: thumbnail._id });
}
//#endregion
console.log('done', file._id);
}));
console.log('ALL DONE');
});
async function job(file: IDriveFile): Promise<any> {
file = await DriveFile.findOne({ _id: file._id });
const minio = new Minio.Client(config.drive.config);
const name = file.filename.substr(0, 50);
const keyDir = `${config.drive.prefix}/${uuid.v4()}`;
const key = `${keyDir}/${name}`;
const thumbnailKeyDir = `${config.drive.prefix}/${uuid.v4()}`;
const thumbnailKey = `${thumbnailKeyDir}/${name}.thumbnail.jpg`;
const baseUrl = config.drive.baseUrl
|| `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? `:${config.drive.config.port}` : '' }/${ config.drive.bucket }`;
const bucket = await getDriveFileBucket();
const readable = bucket.openDownloadStream(file._id);
await minio.putObject(config.drive.bucket, key, readable, file.length, {
'Content-Type': file.contentType,
'Cache-Control': 'max-age=31536000, immutable'
});
await DriveFile.findOneAndUpdate({ _id: file._id }, {
$set: {
'metadata.withoutChunks': true,
'metadata.storage': 'minio',
'metadata.storageProps': {
key: key,
thumbnailKey: thumbnailKey
},
'metadata.url': `${ baseUrl }/${ keyDir }/${ encodeURIComponent(name) }`,
}
});
// チャンクをすべて削除
await DriveFileChunk.remove({
files_id: file._id
});
//#region サムネイルもあれば削除
const thumbnail = await DriveFileThumbnail.findOne({
'metadata.originalId': file._id
});
if (thumbnail) {
await DriveFileThumbnailChunk.remove({
files_id: thumbnail._id
});
await DriveFileThumbnail.remove({ _id: thumbnail._id });
}
//#endregion
console.log('done', file._id);
}