forked from FoundKeyGang/FoundKey
Introduce publishers directory
This commit is contained in:
parent
0a48ef59cd
commit
ad38cd2605
27 changed files with 48 additions and 52 deletions
|
@ -13,7 +13,7 @@ import prominence = require('prominence');
|
||||||
import DriveFile, { getGridFSBucket } from '../models/drive-file';
|
import DriveFile, { getGridFSBucket } from '../models/drive-file';
|
||||||
import DriveFolder from '../models/drive-folder';
|
import DriveFolder from '../models/drive-folder';
|
||||||
import { pack } from '../models/drive-file';
|
import { pack } from '../models/drive-file';
|
||||||
import event, { publishDriveStream } from '../event';
|
import event, { publishDriveStream } from '../publishers/stream';
|
||||||
import getAcct from '../user/get-acct';
|
import getAcct from '../user/get-acct';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { sign } from 'http-signature';
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
import User, { isLocalUser, pack as packUser, ILocalUser } from '../../models/user';
|
import User, { isLocalUser, pack as packUser, ILocalUser } from '../../models/user';
|
||||||
import Following from '../../models/following';
|
import Following from '../../models/following';
|
||||||
import event from '../../event';
|
import event from '../../publishers/stream';
|
||||||
import notify from '../../notify';
|
import notify from '../../publishers/notify';
|
||||||
import context from '../../remote/activitypub/renderer/context';
|
import context from '../../remote/activitypub/renderer/context';
|
||||||
import render from '../../remote/activitypub/renderer/follow';
|
import render from '../../remote/activitypub/renderer/follow';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import Notification from './models/notification';
|
import Notification from '../models/notification';
|
||||||
import Mute from './models/mute';
|
import Mute from '../models/mute';
|
||||||
import event from './event';
|
import { pack } from '../models/notification';
|
||||||
import { pack } from './models/notification';
|
import stream from './stream';
|
||||||
|
|
||||||
export default (
|
export default (
|
||||||
notifiee: mongo.ObjectID,
|
notifiee: mongo.ObjectID,
|
||||||
|
@ -26,7 +26,7 @@ export default (
|
||||||
resolve(notification);
|
resolve(notification);
|
||||||
|
|
||||||
// Publish notification event
|
// Publish notification event
|
||||||
event(notifiee, 'notification',
|
stream(notifiee, 'notification',
|
||||||
await pack(notification));
|
await pack(notification));
|
||||||
|
|
||||||
// 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
|
// 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
|
||||||
|
@ -44,7 +44,7 @@ export default (
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
event(notifiee, 'unread_notification', await pack(notification));
|
stream(notifiee, 'unread_notification', await pack(notification));
|
||||||
}
|
}
|
||||||
}, 3000);
|
}, 3000);
|
||||||
});
|
});
|
|
@ -1,7 +1,7 @@
|
||||||
const push = require('web-push');
|
const push = require('web-push');
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import Subscription from './models/sw-subscription';
|
import Subscription from '../models/sw-subscription';
|
||||||
import config from './config';
|
import config from '../config';
|
||||||
|
|
||||||
if (config.sw) {
|
if (config.sw) {
|
||||||
// アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録
|
// アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録
|
|
@ -1,7 +1,6 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import * as redis from 'redis';
|
import * as redis from 'redis';
|
||||||
import swPush from './push-sw';
|
import config from '../config';
|
||||||
import config from './config';
|
|
||||||
|
|
||||||
type ID = string | mongo.ObjectID;
|
type ID = string | mongo.ObjectID;
|
||||||
|
|
||||||
|
@ -18,10 +17,6 @@ class MisskeyEvent {
|
||||||
this.publish(`user-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
this.publish(`user-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public publishSw(userId: ID, type: string, value?: any): void {
|
|
||||||
swPush(userId, type, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public publishDriveStream(userId: ID, type: string, value?: any): void {
|
public publishDriveStream(userId: ID, type: string, value?: any): void {
|
||||||
this.publish(`drive-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
this.publish(`drive-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
|
||||||
}
|
}
|
||||||
|
@ -63,8 +58,6 @@ const ev = new MisskeyEvent();
|
||||||
|
|
||||||
export default ev.publishUserStream.bind(ev);
|
export default ev.publishUserStream.bind(ev);
|
||||||
|
|
||||||
export const pushSw = ev.publishSw.bind(ev);
|
|
||||||
|
|
||||||
export const publishDriveStream = ev.publishDriveStream.bind(ev);
|
export const publishDriveStream = ev.publishDriveStream.bind(ev);
|
||||||
|
|
||||||
export const publishPostStream = ev.publishPostStream.bind(ev);
|
export const publishPostStream = ev.publishPostStream.bind(ev);
|
|
@ -1,9 +1,9 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import Message from '../../../models/messaging-message';
|
import Message from '../../../models/messaging-message';
|
||||||
import { IMessagingMessage as IMessage } from '../../../models/messaging-message';
|
import { IMessagingMessage as IMessage } from '../../../models/messaging-message';
|
||||||
import publishUserStream from '../../../event';
|
import publishUserStream from '../../../publishers/stream';
|
||||||
import { publishMessagingStream } from '../../../event';
|
import { publishMessagingStream } from '../../../publishers/stream';
|
||||||
import { publishMessagingIndexStream } from '../../../event';
|
import { publishMessagingIndexStream } from '../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark as read message(s)
|
* Mark as read message(s)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import { default as Notification, INotification } from '../../../models/notification';
|
import { default as Notification, INotification } from '../../../models/notification';
|
||||||
import publishUserStream from '../../../event';
|
import publishUserStream from '../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark as read notification(s)
|
* Mark as read notification(s)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder from '../../../../../models/drive-folder';
|
import DriveFolder from '../../../../../models/drive-folder';
|
||||||
import DriveFile, { validateFileName, pack } from '../../../../../models/drive-file';
|
import DriveFile, { validateFileName, pack } from '../../../../../models/drive-file';
|
||||||
import { publishDriveStream } from '../../../../../event';
|
import { publishDriveStream } from '../../../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a file
|
* Update a file
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
|
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
|
||||||
import { publishDriveStream } from '../../../../../event';
|
import { publishDriveStream } from '../../../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create drive folder
|
* Create drive folder
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
|
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
|
||||||
import { publishDriveStream } from '../../../../../event';
|
import { publishDriveStream } from '../../../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a folder
|
* Update a folder
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User, { pack as packUser } from '../../../../models/user';
|
import User, { pack as packUser } from '../../../../models/user';
|
||||||
import Following from '../../../../models/following';
|
import Following from '../../../../models/following';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfollow a user
|
* Unfollow a user
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import * as bcrypt from 'bcryptjs';
|
import * as bcrypt from 'bcryptjs';
|
||||||
import User from '../../../../models/user';
|
import User from '../../../../models/user';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
import generateUserToken from '../../common/generate-native-user-token';
|
import generateUserToken from '../../common/generate-native-user-token';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
import config from '../../../../config';
|
import config from '../../../../config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User, { pack } from '../../../../models/user';
|
import User, { pack } from '../../../../models/user';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update myself
|
* Update myself
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../../../models/user';
|
import User from '../../../../models/user';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
|
|
||||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
// Get 'home' parameter
|
// Get 'home' parameter
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../../../models/user';
|
import User from '../../../../models/user';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
|
|
||||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
// Get 'home' parameter
|
// Get 'home' parameter
|
||||||
|
|
|
@ -9,8 +9,9 @@ import User from '../../../../../models/user';
|
||||||
import Mute from '../../../../../models/mute';
|
import Mute from '../../../../../models/mute';
|
||||||
import DriveFile from '../../../../../models/drive-file';
|
import DriveFile from '../../../../../models/drive-file';
|
||||||
import { pack } from '../../../../../models/messaging-message';
|
import { pack } from '../../../../../models/messaging-message';
|
||||||
import publishUserStream from '../../../../../event';
|
import publishUserStream from '../../../../../publishers/stream';
|
||||||
import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../../../event';
|
import { publishMessagingStream, publishMessagingIndexStream } from '../../../../../publishers/stream';
|
||||||
|
import pushSw from '../../../../../publishers/push-sw';
|
||||||
import html from '../../../../../text/html';
|
import html from '../../../../../text/html';
|
||||||
import parse from '../../../../../text/parse';
|
import parse from '../../../../../text/parse';
|
||||||
import config from '../../../../../config';
|
import config from '../../../../../config';
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Module dependencies
|
* Module dependencies
|
||||||
*/
|
*/
|
||||||
import Notification from '../../../../models/notification';
|
import Notification from '../../../../models/notification';
|
||||||
import event from '../../../../event';
|
import event from '../../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark as read all notifications
|
* Mark as read all notifications
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
|
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
|
||||||
import OthelloGame, { pack as packGame } from '../../../../models/othello-game';
|
import OthelloGame, { pack as packGame } from '../../../../models/othello-game';
|
||||||
import User from '../../../../models/user';
|
import User from '../../../../models/user';
|
||||||
import publishUserStream, { publishOthelloStream } from '../../../../event';
|
import publishUserStream, { publishOthelloStream } from '../../../../publishers/stream';
|
||||||
import { eighteight } from '../../../../othello/maps';
|
import { eighteight } from '../../../../othello/maps';
|
||||||
|
|
||||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
|
@ -15,8 +15,9 @@ import Watching from '../../../../models/post-watching';
|
||||||
import ChannelWatching from '../../../../models/channel-watching';
|
import ChannelWatching from '../../../../models/channel-watching';
|
||||||
import { pack } from '../../../../models/post';
|
import { pack } from '../../../../models/post';
|
||||||
import watch from '../../common/watch-post';
|
import watch from '../../common/watch-post';
|
||||||
import event, { pushSw, publishChannelStream } from '../../../../event';
|
import stream, { publishChannelStream } from '../../../../publishers/stream';
|
||||||
import notify from '../../../../notify';
|
import notify from '../../../../publishers/notify';
|
||||||
|
import pushSw from '../../../../publishers/push-sw';
|
||||||
import getAcct from '../../../../user/get-acct';
|
import getAcct from '../../../../user/get-acct';
|
||||||
import parseAcct from '../../../../user/parse-acct';
|
import parseAcct from '../../../../user/parse-acct';
|
||||||
import config from '../../../../config';
|
import config from '../../../../config';
|
||||||
|
@ -306,7 +307,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
|
||||||
});
|
});
|
||||||
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
|
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId.toString());
|
||||||
if (mentioneesMutedUserIds.indexOf(user._id.toString()) == -1) {
|
if (mentioneesMutedUserIds.indexOf(user._id.toString()) == -1) {
|
||||||
event(mentionee, reason, postObj);
|
stream(mentionee, reason, postObj);
|
||||||
pushSw(mentionee, reason, postObj);
|
pushSw(mentionee, reason, postObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +316,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
|
||||||
// タイムラインへの投稿
|
// タイムラインへの投稿
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
// Publish event to myself's stream
|
// Publish event to myself's stream
|
||||||
event(user._id, 'post', postObj);
|
stream(user._id, 'post', postObj);
|
||||||
|
|
||||||
// Fetch all followers
|
// Fetch all followers
|
||||||
const followers = await Following
|
const followers = await Following
|
||||||
|
@ -330,7 +331,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
|
||||||
|
|
||||||
// Publish event to followers stream
|
// Publish event to followers stream
|
||||||
followers.forEach(following =>
|
followers.forEach(following =>
|
||||||
event(following.followerId, 'post', postObj));
|
stream(following.followerId, 'post', postObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
// チャンネルへの投稿
|
// チャンネルへの投稿
|
||||||
|
@ -354,7 +355,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
|
||||||
|
|
||||||
// チャンネルの視聴者(のタイムライン)に配信
|
// チャンネルの視聴者(のタイムライン)に配信
|
||||||
watches.forEach(w => {
|
watches.forEach(w => {
|
||||||
event(w.userId, 'post', postObj);
|
stream(w.userId, 'post', postObj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +449,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
|
||||||
} else {
|
} else {
|
||||||
// Publish event
|
// Publish event
|
||||||
if (!user._id.equals(repost.userId)) {
|
if (!user._id.equals(repost.userId)) {
|
||||||
event(repost.userId, 'repost', postObj);
|
stream(repost.userId, 'repost', postObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import Vote from '../../../../../models/poll-vote';
|
||||||
import Post from '../../../../../models/post';
|
import Post from '../../../../../models/post';
|
||||||
import Watching from '../../../../../models/post-watching';
|
import Watching from '../../../../../models/post-watching';
|
||||||
import watch from '../../../common/watch-post';
|
import watch from '../../../common/watch-post';
|
||||||
import { publishPostStream } from '../../../../../event';
|
import { publishPostStream } from '../../../../../publishers/stream';
|
||||||
import notify from '../../../../../notify';
|
import notify from '../../../../../publishers/notify';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vote poll of a post
|
* Vote poll of a post
|
||||||
|
|
|
@ -7,8 +7,9 @@ import Post, { pack as packPost } from '../../../../../models/post';
|
||||||
import { pack as packUser } from '../../../../../models/user';
|
import { pack as packUser } from '../../../../../models/user';
|
||||||
import Watching from '../../../../../models/post-watching';
|
import Watching from '../../../../../models/post-watching';
|
||||||
import watch from '../../../common/watch-post';
|
import watch from '../../../common/watch-post';
|
||||||
import { publishPostStream, pushSw } from '../../../../../event';
|
import { publishPostStream } from '../../../../../publishers/stream';
|
||||||
import notify from '../../../../../notify';
|
import notify from '../../../../../publishers/notify';
|
||||||
|
import pushSw from '../../../../../publishers/push-sw';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React to a post
|
* React to a post
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Reaction from '../../../../../models/post-reaction';
|
import Reaction from '../../../../../models/post-reaction';
|
||||||
import Post from '../../../../../models/post';
|
import Post from '../../../../../models/post';
|
||||||
// import event from '../../../event';
|
// import event from '../../../publishers/stream';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unreact to a post
|
* Unreact to a post
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as bcrypt from 'bcryptjs';
|
||||||
import * as speakeasy from 'speakeasy';
|
import * as speakeasy from 'speakeasy';
|
||||||
import User, { ILocalUser } from '../../../models/user';
|
import User, { ILocalUser } from '../../../models/user';
|
||||||
import Signin, { pack } from '../../../models/signin';
|
import Signin, { pack } from '../../../models/signin';
|
||||||
import event from '../../../event';
|
import event from '../../../publishers/stream';
|
||||||
import signin from '../common/signin';
|
import signin from '../common/signin';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import * as uuid from 'uuid';
|
||||||
import autwh from 'autwh';
|
import autwh from 'autwh';
|
||||||
import redis from '../../../db/redis';
|
import redis from '../../../db/redis';
|
||||||
import User, { pack } from '../../../models/user';
|
import User, { pack } from '../../../models/user';
|
||||||
import event from '../../../event';
|
import event from '../../../publishers/stream';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
import signin from '../common/signin';
|
import signin from '../common/signin';
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as websocket from 'websocket';
|
||||||
import * as redis from 'redis';
|
import * as redis from 'redis';
|
||||||
import * as CRC32 from 'crc-32';
|
import * as CRC32 from 'crc-32';
|
||||||
import OthelloGame, { pack } from '../../../models/othello-game';
|
import OthelloGame, { pack } from '../../../models/othello-game';
|
||||||
import { publishOthelloGameStream } from '../../../event';
|
import { publishOthelloGameStream } from '../../../publishers/stream';
|
||||||
import Othello from '../../../othello/core';
|
import Othello from '../../../othello/core';
|
||||||
import * as maps from '../../../othello/maps';
|
import * as maps from '../../../othello/maps';
|
||||||
import { ParsedUrlQuery } from 'querystring';
|
import { ParsedUrlQuery } from 'querystring';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as mongo from 'mongodb';
|
||||||
import * as websocket from 'websocket';
|
import * as websocket from 'websocket';
|
||||||
import * as redis from 'redis';
|
import * as redis from 'redis';
|
||||||
import Matching, { pack } from '../../../models/othello-matching';
|
import Matching, { pack } from '../../../models/othello-matching';
|
||||||
import publishUserStream from '../../../event';
|
import publishUserStream from '../../../publishers/stream';
|
||||||
|
|
||||||
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
|
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
|
||||||
// Subscribe othello stream
|
// Subscribe othello stream
|
||||||
|
|
Loading…
Reference in a new issue