Resolve #2691
This commit is contained in:
parent
bb8139196e
commit
046976dffc
7 changed files with 142 additions and 62 deletions
|
@ -2,8 +2,8 @@
|
||||||
<div class="mk-timeline">
|
<div class="mk-timeline">
|
||||||
<header>
|
<header>
|
||||||
<span :data-active="src == 'home'" @click="src = 'home'">%fa:home% %i18n:@home%</span>
|
<span :data-active="src == 'home'" @click="src = 'home'">%fa:home% %i18n:@home%</span>
|
||||||
<span :data-active="src == 'local'" @click="src = 'local'">%fa:R comments% %i18n:@local%</span>
|
<span :data-active="src == 'local'" @click="src = 'local'" v-if="enableLocalTimeline">%fa:R comments% %i18n:@local%</span>
|
||||||
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'">%fa:share-alt% %i18n:@hybrid%</span>
|
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'" v-if="enableLocalTimeline">%fa:share-alt% %i18n:@hybrid%</span>
|
||||||
<span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span>
|
<span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span>
|
||||||
<span :data-active="src == 'list'" @click="src = 'list'" v-if="list">%fa:list% {{ list.title }}</span>
|
<span :data-active="src == 'list'" @click="src = 'list'" v-if="list">%fa:list% {{ list.title }}</span>
|
||||||
<button @click="chooseList" title="%i18n:@list%">%fa:list%</button>
|
<button @click="chooseList" title="%i18n:@list%">%fa:list%</button>
|
||||||
|
@ -29,7 +29,8 @@ export default Vue.extend({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
src: 'home',
|
src: 'home',
|
||||||
list: null
|
list: null,
|
||||||
|
enableLocalTimeline: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -44,6 +45,10 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
(this as any).os.getMeta().then(meta => {
|
||||||
|
this.enableLocalTimeline = !meta.disableLocalTimeline;
|
||||||
|
});
|
||||||
|
|
||||||
if (this.$store.state.device.tl) {
|
if (this.$store.state.device.tl) {
|
||||||
this.src = this.$store.state.device.tl.src;
|
this.src = this.$store.state.device.tl.src;
|
||||||
if (this.src == 'list') {
|
if (this.src == 'list') {
|
||||||
|
|
|
@ -1,23 +1,35 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="obdskegsannmntldydackcpzezagxqfy mk-admin-card">
|
<div class="obdskegsannmntldydackcpzezagxqfy mk-admin-card">
|
||||||
<header>%i18n:@dashboard%</header>
|
<header>%i18n:@dashboard%</header>
|
||||||
|
|
||||||
<div v-if="stats" class="stats">
|
<div v-if="stats" class="stats">
|
||||||
<div><b>%fa:user% {{ stats.originalUsersCount | number }}</b><span>%i18n:@original-users%</span></div>
|
<div><b>%fa:user% {{ stats.originalUsersCount | number }}</b><span>%i18n:@original-users%</span></div>
|
||||||
<div><span>%fa:user% {{ stats.usersCount | number }}</span><span>%i18n:@all-users%</span></div>
|
<div><span>%fa:user% {{ stats.usersCount | number }}</span><span>%i18n:@all-users%</span></div>
|
||||||
<div><b>%fa:pencil-alt% {{ stats.originalNotesCount | number }}</b><span>%i18n:@original-notes%</span></div>
|
<div><b>%fa:pencil-alt% {{ stats.originalNotesCount | number }}</b><span>%i18n:@original-notes%</span></div>
|
||||||
<div><span>%fa:pencil-alt% {{ stats.notesCount | number }}</span><span>%i18n:@all-notes%</span></div>
|
<div><span>%fa:pencil-alt% {{ stats.notesCount | number }}</span><span>%i18n:@all-notes%</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cpu-memory">
|
<div class="cpu-memory">
|
||||||
<x-cpu-memory :connection="connection"/>
|
<x-cpu-memory :connection="connection"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form">
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" v-model="disableRegistration" @change="updateMeta">
|
<input type="checkbox" v-model="disableRegistration" @change="updateMeta">
|
||||||
<span>disableRegistration</span>
|
<span>%i18n:@disableRegistration%</span>
|
||||||
</label>
|
</label>
|
||||||
<button class="ui" @click="invite">%i18n:@invite%</button>
|
<button class="ui" @click="invite">%i18n:@invite%</button>
|
||||||
<p v-if="inviteCode">Code: <code>{{ inviteCode }}</code></p>
|
<p v-if="inviteCode">Code: <code>{{ inviteCode }}</code></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="disableLocalTimeline" @change="updateMeta">
|
||||||
|
<span>%i18n:@disableLocalTimeline%</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -33,6 +45,7 @@ export default Vue.extend({
|
||||||
return {
|
return {
|
||||||
stats: null,
|
stats: null,
|
||||||
disableRegistration: false,
|
disableRegistration: false,
|
||||||
|
disableLocalTimeline: false,
|
||||||
inviteCode: null,
|
inviteCode: null,
|
||||||
connection: null,
|
connection: null,
|
||||||
connectionId: null
|
connectionId: null
|
||||||
|
@ -44,6 +57,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
(this as any).os.getMeta().then(meta => {
|
(this as any).os.getMeta().then(meta => {
|
||||||
this.disableRegistration = meta.disableRegistration;
|
this.disableRegistration = meta.disableRegistration;
|
||||||
|
this.disableLocalTimeline = meta.disableLocalTimeline;
|
||||||
});
|
});
|
||||||
|
|
||||||
(this as any).api('stats').then(stats => {
|
(this as any).api('stats').then(stats => {
|
||||||
|
@ -61,7 +75,8 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
updateMeta() {
|
updateMeta() {
|
||||||
(this as any).api('admin/update-meta', {
|
(this as any).api('admin/update-meta', {
|
||||||
disableRegistration: this.disableRegistration
|
disableRegistration: this.disableRegistration,
|
||||||
|
disableLocalTimeline: this.disableLocalTimeline
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,4 +112,8 @@ export default Vue.extend({
|
||||||
border solid 1px #eee
|
border solid 1px #eee
|
||||||
border-radius: 8px
|
border-radius: 8px
|
||||||
|
|
||||||
|
> .form
|
||||||
|
> div
|
||||||
|
border-bottom solid 1px #eee
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div>
|
<div>
|
||||||
<span :data-active="src == 'home'" @click="src = 'home'">%fa:home% %i18n:@home%</span>
|
<span :data-active="src == 'home'" @click="src = 'home'">%fa:home% %i18n:@home%</span>
|
||||||
<span :data-active="src == 'local'" @click="src = 'local'">%fa:R comments% %i18n:@local%</span>
|
<span :data-active="src == 'local'" @click="src = 'local'" v-if="enableLocalTimeline">%fa:R comments% %i18n:@local%</span>
|
||||||
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'">%fa:share-alt% %i18n:@hybrid%</span>
|
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'" v-if="enableLocalTimeline">%fa:share-alt% %i18n:@hybrid%</span>
|
||||||
<span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span>
|
<span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span>
|
||||||
<template v-if="lists">
|
<template v-if="lists">
|
||||||
<span v-for="l in lists" :data-active="src == 'list' && list == l" @click="src = 'list'; list = l" :key="l.id">%fa:list% {{ l.title }}</span>
|
<span v-for="l in lists" :data-active="src == 'list' && list == l" @click="src = 'list'; list = l" :key="l.id">%fa:list% {{ l.title }}</span>
|
||||||
|
@ -60,7 +60,8 @@ export default Vue.extend({
|
||||||
src: 'home',
|
src: 'home',
|
||||||
list: null,
|
list: null,
|
||||||
lists: null,
|
lists: null,
|
||||||
showNav: false
|
showNav: false,
|
||||||
|
enableLocalTimeline: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -85,6 +86,10 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
(this as any).os.getMeta().then(meta => {
|
||||||
|
this.enableLocalTimeline = !meta.disableLocalTimeline;
|
||||||
|
});
|
||||||
|
|
||||||
if (this.$store.state.device.tl) {
|
if (this.$store.state.device.tl) {
|
||||||
this.src = this.$store.state.device.tl.src;
|
this.src = this.$store.state.device.tl.src;
|
||||||
if (this.src == 'list') {
|
if (this.src == 'list') {
|
||||||
|
|
|
@ -12,5 +12,6 @@ export type IMeta = {
|
||||||
originalUsersCount: number;
|
originalUsersCount: number;
|
||||||
};
|
};
|
||||||
disableRegistration?: boolean;
|
disableRegistration?: boolean;
|
||||||
|
disableLocalTimeline?: boolean;
|
||||||
hidedTags?: string[];
|
hidedTags?: string[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,6 +23,12 @@ export const meta = {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
disableLocalTimeline: $.bool.optional.nullable.note({
|
||||||
|
desc: {
|
||||||
|
'ja-JP': 'ローカルタイムライン(とソーシャルタイムライン)を無効にするか否か'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
hidedTags: $.arr($.str).optional.nullable.note({
|
hidedTags: $.arr($.str).optional.nullable.note({
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': '統計などで無視するハッシュタグ'
|
'ja-JP': '統計などで無視するハッシュタグ'
|
||||||
|
@ -45,6 +51,10 @@ export default (params: any) => new Promise(async (res, rej) => {
|
||||||
set.disableRegistration = ps.disableRegistration;
|
set.disableRegistration = ps.disableRegistration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof ps.disableLocalTimeline === 'boolean') {
|
||||||
|
set.disableLocalTimeline = ps.disableLocalTimeline;
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(ps.hidedTags)) {
|
if (Array.isArray(ps.hidedTags)) {
|
||||||
set.hidedTags = ps.hidedTags;
|
set.hidedTags = ps.hidedTags;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||||
},
|
},
|
||||||
broadcasts: meta.broadcasts,
|
broadcasts: meta.broadcasts,
|
||||||
disableRegistration: meta.disableRegistration,
|
disableRegistration: meta.disableRegistration,
|
||||||
|
disableLocalTimeline: meta.disableLocalTimeline,
|
||||||
driveCapacityPerLocalUserMb: config.localDriveCapacityMb,
|
driveCapacityPerLocalUserMb: config.localDriveCapacityMb,
|
||||||
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
|
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
|
||||||
swPublickey: config.sw ? config.sw.public_key : null,
|
swPublickey: config.sw ? config.sw.public_key : null,
|
||||||
|
|
129
src/stream.ts
129
src/stream.ts
|
@ -1,58 +1,97 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import Xev from 'xev';
|
import Xev from 'xev';
|
||||||
|
import Meta, { IMeta } from './models/meta';
|
||||||
const ev = new Xev();
|
|
||||||
|
|
||||||
type ID = string | mongo.ObjectID;
|
type ID = string | mongo.ObjectID;
|
||||||
|
|
||||||
function publish(channel: string, type: string, value?: any): void {
|
class Publisher {
|
||||||
|
private ev: Xev;
|
||||||
|
private meta: IMeta;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.ev = new Xev();
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
this.meta = await Meta.findOne({});
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getMeta = async () => {
|
||||||
|
if (this.meta != null) return this.meta;
|
||||||
|
|
||||||
|
this.meta = await Meta.findOne({});
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
private publish = (channel: string, type: string, value?: any): void => {
|
||||||
const message = type == null ? value : value == null ?
|
const message = type == null ? value : value == null ?
|
||||||
{ type: type } :
|
{ type: type } :
|
||||||
{ type: type, body: value };
|
{ type: type, body: value };
|
||||||
|
|
||||||
ev.emit(channel, message);
|
this.ev.emit(channel, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishUserStream = (userId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`user-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishDriveStream = (userId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`drive-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishNoteStream = (noteId: ID, type: string): void => {
|
||||||
|
this.publish(`note-stream:${noteId}`, null, noteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishUserListStream = (listId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`user-list-stream:${listId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishMessagingStream = (userId: ID, otherpartyId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`messaging-stream:${userId}-${otherpartyId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishMessagingIndexStream = (userId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`messaging-index-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishReversiStream = (userId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`reversi-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishReversiGameStream = (gameId: ID, type: string, value?: any): void => {
|
||||||
|
this.publish(`reversi-game-stream:${gameId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishLocalTimelineStream = async (note: any): Promise<void> => {
|
||||||
|
const meta = await this.getMeta();
|
||||||
|
if (meta.disableLocalTimeline) return;
|
||||||
|
this.publish('local-timeline', null, note);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishHybridTimelineStream = async (userId: ID, note: any): Promise<void> => {
|
||||||
|
const meta = await this.getMeta();
|
||||||
|
if (meta.disableLocalTimeline) return;
|
||||||
|
this.publish(userId ? `hybrid-timeline:${userId}` : 'hybrid-timeline', null, note);
|
||||||
|
}
|
||||||
|
|
||||||
|
public publishGlobalTimelineStream = (note: any): void => {
|
||||||
|
this.publish('global-timeline', null, note);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function publishUserStream(userId: ID, type: string, value?: any): void {
|
const publisher = new Publisher();
|
||||||
publish(`user-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishDriveStream(userId: ID, type: string, value?: any): void {
|
export default publisher;
|
||||||
publish(`drive-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishNoteStream(noteId: ID, type: string): void {
|
export const publishUserStream = publisher.publishUserStream;
|
||||||
publish(`note-stream:${noteId}`, null, noteId);
|
export const publishDriveStream = publisher.publishDriveStream;
|
||||||
}
|
export const publishNoteStream = publisher.publishNoteStream;
|
||||||
|
export const publishUserListStream = publisher.publishUserListStream;
|
||||||
export function publishUserListStream(listId: ID, type: string, value?: any): void {
|
export const publishMessagingStream = publisher.publishMessagingStream;
|
||||||
publish(`user-list-stream:${listId}`, type, typeof value === 'undefined' ? null : value);
|
export const publishMessagingIndexStream = publisher.publishMessagingIndexStream;
|
||||||
}
|
export const publishReversiStream = publisher.publishReversiStream;
|
||||||
|
export const publishReversiGameStream = publisher.publishReversiGameStream;
|
||||||
export function publishMessagingStream(userId: ID, otherpartyId: ID, type: string, value?: any): void {
|
export const publishLocalTimelineStream = publisher.publishLocalTimelineStream;
|
||||||
publish(`messaging-stream:${userId}-${otherpartyId}`, type, typeof value === 'undefined' ? null : value);
|
export const publishHybridTimelineStream = publisher.publishHybridTimelineStream;
|
||||||
}
|
export const publishGlobalTimelineStream = publisher.publishGlobalTimelineStream;
|
||||||
|
|
||||||
export function publishMessagingIndexStream(userId: ID, type: string, value?: any): void {
|
|
||||||
publish(`messaging-index-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishReversiStream(userId: ID, type: string, value?: any): void {
|
|
||||||
publish(`reversi-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishReversiGameStream(gameId: ID, type: string, value?: any): void {
|
|
||||||
publish(`reversi-game-stream:${gameId}`, type, typeof value === 'undefined' ? null : value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishLocalTimelineStream(note: any): void {
|
|
||||||
publish('local-timeline', null, note);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishHybridTimelineStream(userId: ID, note: any): void {
|
|
||||||
publish(userId ? `hybrid-timeline:${userId}` : 'hybrid-timeline', null, note);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function publishGlobalTimelineStream(note: any): void {
|
|
||||||
publish('global-timeline', null, note);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue