1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-02 08:48:11 +09:00

Introduce publishers directory

This commit is contained in:
Akihiko Odaki 2018-04-02 13:33:46 +09:00
parent 0a48ef59cd
commit ad38cd2605
27 changed files with 48 additions and 52 deletions

View File

@ -13,7 +13,7 @@ import prominence = require('prominence');
import DriveFile, { getGridFSBucket } from '../models/drive-file';
import DriveFolder from '../models/drive-folder';
import { pack } from '../models/drive-file';
import event, { publishDriveStream } from '../event';
import event, { publishDriveStream } from '../publishers/stream';
import getAcct from '../user/get-acct';
import config from '../config';

View File

@ -3,8 +3,8 @@ import { sign } from 'http-signature';
import { URL } from 'url';
import User, { isLocalUser, pack as packUser, ILocalUser } from '../../models/user';
import Following from '../../models/following';
import event from '../../event';
import notify from '../../notify';
import event from '../../publishers/stream';
import notify from '../../publishers/notify';
import context from '../../remote/activitypub/renderer/context';
import render from '../../remote/activitypub/renderer/follow';
import config from '../../config';

View File

@ -1,8 +1,8 @@
import * as mongo from 'mongodb';
import Notification from './models/notification';
import Mute from './models/mute';
import event from './event';
import { pack } from './models/notification';
import Notification from '../models/notification';
import Mute from '../models/mute';
import { pack } from '../models/notification';
import stream from './stream';
export default (
notifiee: mongo.ObjectID,
@ -26,7 +26,7 @@ export default (
resolve(notification);
// Publish notification event
event(notifiee, 'notification',
stream(notifiee, 'notification',
await pack(notification));
// 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
@ -44,7 +44,7 @@ export default (
}
//#endregion
event(notifiee, 'unread_notification', await pack(notification));
stream(notifiee, 'unread_notification', await pack(notification));
}
}, 3000);
});

View File

@ -1,7 +1,7 @@
const push = require('web-push');
import * as mongo from 'mongodb';
import Subscription from './models/sw-subscription';
import config from './config';
import Subscription from '../models/sw-subscription';
import config from '../config';
if (config.sw) {
// アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録

View File

@ -1,7 +1,6 @@
import * as mongo from 'mongodb';
import * as redis from 'redis';
import swPush from './push-sw';
import config from './config';
import config from '../config';
type ID = string | mongo.ObjectID;
@ -18,10 +17,6 @@ class MisskeyEvent {
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 {
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 const pushSw = ev.publishSw.bind(ev);
export const publishDriveStream = ev.publishDriveStream.bind(ev);
export const publishPostStream = ev.publishPostStream.bind(ev);

View File

@ -1,9 +1,9 @@
import * as mongo from 'mongodb';
import Message from '../../../models/messaging-message';
import { IMessagingMessage as IMessage } from '../../../models/messaging-message';
import publishUserStream from '../../../event';
import { publishMessagingStream } from '../../../event';
import { publishMessagingIndexStream } from '../../../event';
import publishUserStream from '../../../publishers/stream';
import { publishMessagingStream } from '../../../publishers/stream';
import { publishMessagingIndexStream } from '../../../publishers/stream';
/**
* Mark as read message(s)

View File

@ -1,6 +1,6 @@
import * as mongo from 'mongodb';
import { default as Notification, INotification } from '../../../models/notification';
import publishUserStream from '../../../event';
import publishUserStream from '../../../publishers/stream';
/**
* Mark as read notification(s)

View File

@ -4,7 +4,7 @@
import $ from 'cafy';
import DriveFolder from '../../../../../models/drive-folder';
import DriveFile, { validateFileName, pack } from '../../../../../models/drive-file';
import { publishDriveStream } from '../../../../../event';
import { publishDriveStream } from '../../../../../publishers/stream';
/**
* Update a file

View File

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
import { publishDriveStream } from '../../../../../event';
import { publishDriveStream } from '../../../../../publishers/stream';
/**
* Create drive folder

View File

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
import { publishDriveStream } from '../../../../../event';
import { publishDriveStream } from '../../../../../publishers/stream';
/**
* Update a folder

View File

@ -4,7 +4,7 @@
import $ from 'cafy';
import User, { pack as packUser } from '../../../../models/user';
import Following from '../../../../models/following';
import event from '../../../../event';
import event from '../../../../publishers/stream';
/**
* Unfollow a user

View File

@ -4,7 +4,7 @@
import $ from 'cafy';
import * as bcrypt from 'bcryptjs';
import User from '../../../../models/user';
import event from '../../../../event';
import event from '../../../../publishers/stream';
import generateUserToken from '../../common/generate-native-user-token';
/**

View File

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
import event from '../../../../event';
import event from '../../../../publishers/stream';
import config from '../../../../config';
/**

View File

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User, { pack } from '../../../../models/user';
import event from '../../../../event';
import event from '../../../../publishers/stream';
/**
* Update myself

View File

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User from '../../../../models/user';
import event from '../../../../event';
import event from '../../../../publishers/stream';
module.exports = async (params, user) => new Promise(async (res, rej) => {
// Get 'home' parameter

View File

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User from '../../../../models/user';
import event from '../../../../event';
import event from '../../../../publishers/stream';
module.exports = async (params, user) => new Promise(async (res, rej) => {
// Get 'home' parameter

View File

@ -9,8 +9,9 @@ import User from '../../../../../models/user';
import Mute from '../../../../../models/mute';
import DriveFile from '../../../../../models/drive-file';
import { pack } from '../../../../../models/messaging-message';
import publishUserStream from '../../../../../event';
import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../../../event';
import publishUserStream from '../../../../../publishers/stream';
import { publishMessagingStream, publishMessagingIndexStream } from '../../../../../publishers/stream';
import pushSw from '../../../../../publishers/push-sw';
import html from '../../../../../text/html';
import parse from '../../../../../text/parse';
import config from '../../../../../config';

View File

@ -2,7 +2,7 @@
* Module dependencies
*/
import Notification from '../../../../models/notification';
import event from '../../../../event';
import event from '../../../../publishers/stream';
/**
* Mark as read all notifications

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
import OthelloGame, { pack as packGame } from '../../../../models/othello-game';
import User from '../../../../models/user';
import publishUserStream, { publishOthelloStream } from '../../../../event';
import publishUserStream, { publishOthelloStream } from '../../../../publishers/stream';
import { eighteight } from '../../../../othello/maps';
module.exports = (params, user) => new Promise(async (res, rej) => {

View File

@ -15,8 +15,9 @@ import Watching from '../../../../models/post-watching';
import ChannelWatching from '../../../../models/channel-watching';
import { pack } from '../../../../models/post';
import watch from '../../common/watch-post';
import event, { pushSw, publishChannelStream } from '../../../../event';
import notify from '../../../../notify';
import stream, { publishChannelStream } from '../../../../publishers/stream';
import notify from '../../../../publishers/notify';
import pushSw from '../../../../publishers/push-sw';
import getAcct from '../../../../user/get-acct';
import parseAcct from '../../../../user/parse-acct';
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());
if (mentioneesMutedUserIds.indexOf(user._id.toString()) == -1) {
event(mentionee, reason, postObj);
stream(mentionee, reason, postObj);
pushSw(mentionee, reason, postObj);
}
}
@ -315,7 +316,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
// タイムラインへの投稿
if (!channel) {
// Publish event to myself's stream
event(user._id, 'post', postObj);
stream(user._id, 'post', postObj);
// Fetch all followers
const followers = await Following
@ -330,7 +331,7 @@ module.exports = (params, user: ILocalUser, app) => new Promise(async (res, rej)
// Publish event to followers stream
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 => {
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 {
// Publish event
if (!user._id.equals(repost.userId)) {
event(repost.userId, 'repost', postObj);
stream(repost.userId, 'repost', postObj);
}
}

View File

@ -6,8 +6,8 @@ import Vote from '../../../../../models/poll-vote';
import Post from '../../../../../models/post';
import Watching from '../../../../../models/post-watching';
import watch from '../../../common/watch-post';
import { publishPostStream } from '../../../../../event';
import notify from '../../../../../notify';
import { publishPostStream } from '../../../../../publishers/stream';
import notify from '../../../../../publishers/notify';
/**
* Vote poll of a post

View File

@ -7,8 +7,9 @@ import Post, { pack as packPost } from '../../../../../models/post';
import { pack as packUser } from '../../../../../models/user';
import Watching from '../../../../../models/post-watching';
import watch from '../../../common/watch-post';
import { publishPostStream, pushSw } from '../../../../../event';
import notify from '../../../../../notify';
import { publishPostStream } from '../../../../../publishers/stream';
import notify from '../../../../../publishers/notify';
import pushSw from '../../../../../publishers/push-sw';
/**
* React to a post

View File

@ -4,7 +4,7 @@
import $ from 'cafy';
import Reaction from '../../../../../models/post-reaction';
import Post from '../../../../../models/post';
// import event from '../../../event';
// import event from '../../../publishers/stream';
/**
* Unreact to a post

View File

@ -3,7 +3,7 @@ import * as bcrypt from 'bcryptjs';
import * as speakeasy from 'speakeasy';
import User, { ILocalUser } from '../../../models/user';
import Signin, { pack } from '../../../models/signin';
import event from '../../../event';
import event from '../../../publishers/stream';
import signin from '../common/signin';
import config from '../../../config';

View File

@ -6,7 +6,7 @@ import * as uuid from 'uuid';
import autwh from 'autwh';
import redis from '../../../db/redis';
import User, { pack } from '../../../models/user';
import event from '../../../event';
import event from '../../../publishers/stream';
import config from '../../../config';
import signin from '../common/signin';

View File

@ -2,7 +2,7 @@ import * as websocket from 'websocket';
import * as redis from 'redis';
import * as CRC32 from 'crc-32';
import OthelloGame, { pack } from '../../../models/othello-game';
import { publishOthelloGameStream } from '../../../event';
import { publishOthelloGameStream } from '../../../publishers/stream';
import Othello from '../../../othello/core';
import * as maps from '../../../othello/maps';
import { ParsedUrlQuery } from 'querystring';

View File

@ -2,7 +2,7 @@ import * as mongo from 'mongodb';
import * as websocket from 'websocket';
import * as redis from 'redis';
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 {
// Subscribe othello stream