Implement #2993
This commit is contained in:
parent
daa22d68fa
commit
a136715111
5 changed files with 153 additions and 0 deletions
|
|
@ -28,6 +28,8 @@ import perUserNotesChart from '../../chart/per-user-notes';
|
|||
|
||||
import { erase, unique } from '../../prelude/array';
|
||||
import insertNoteUnread from './unread';
|
||||
import registerInstance from '../register-instance';
|
||||
import Instance from '../../models/instance';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||
|
||||
|
|
@ -170,6 +172,20 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
|
|||
notesChart.update(note, true);
|
||||
perUserNotesChart.update(user, note, true);
|
||||
|
||||
// Register host
|
||||
if (isRemoteUser(user)) {
|
||||
registerInstance(user.host).then(i => {
|
||||
Instance.update({ _id: i._id }, {
|
||||
$inc: {
|
||||
notesCount: 1
|
||||
}
|
||||
});
|
||||
|
||||
// TODO
|
||||
//perInstanceChart.newNote();
|
||||
});
|
||||
}
|
||||
|
||||
// ハッシュタグ登録
|
||||
tags.map(tag => registerHashtag(user, tag));
|
||||
|
||||
|
|
|
|||
22
src/services/register-instance.ts
Normal file
22
src/services/register-instance.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import Instance, { IInstance } from '../models/instance';
|
||||
import federationChart from '../chart/federation';
|
||||
|
||||
export default async function(host: string): Promise<IInstance> {
|
||||
if (host == null) return null;
|
||||
|
||||
const index = await Instance.findOne({ host });
|
||||
|
||||
if (index == null) {
|
||||
const i = await Instance.insert({
|
||||
host,
|
||||
caughtAt: new Date(),
|
||||
system: null // TODO
|
||||
});
|
||||
|
||||
federationChart.update(true);
|
||||
|
||||
return i;
|
||||
} else {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue