mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 22:22:51 +09:00
メンションを処理
This commit is contained in:
parent
b77cbeca22
commit
1f018d87f2
@ -4,7 +4,7 @@ import webFinger from './webfinger';
|
||||
import config from '../config';
|
||||
import { createPerson } from './activitypub/models/person';
|
||||
|
||||
export default async (username, _host, option) => {
|
||||
export default async (username, _host, option?) => {
|
||||
const usernameLower = username.toLowerCase();
|
||||
const hostAscii = toASCII(_host).toLowerCase();
|
||||
const host = toUnicode(hostAscii);
|
||||
|
@ -17,6 +17,7 @@ import event from '../../publishers/stream';
|
||||
import parse from '../../text/parse';
|
||||
import { IApp } from '../../models/app';
|
||||
import UserList from '../../models/user-list';
|
||||
import resolveUser from '../../remote/resolve-user';
|
||||
|
||||
export default async (user: IUser, data: {
|
||||
createdAt?: Date;
|
||||
@ -119,6 +120,13 @@ export default async (user: IUser, data: {
|
||||
// Serialize
|
||||
const noteObj = await pack(note);
|
||||
|
||||
const render = async () => {
|
||||
const content = data.renote && data.text == null
|
||||
? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
|
||||
: renderCreate(await renderNote(note));
|
||||
return packAp(content);
|
||||
};
|
||||
|
||||
// タイムラインへの投稿
|
||||
if (note.channelId == null) {
|
||||
if (!silent) {
|
||||
@ -190,12 +198,6 @@ export default async (user: IUser, data: {
|
||||
}
|
||||
|
||||
//#region リプライとAnnounceのAP配送
|
||||
const render = async () => {
|
||||
const content = data.renote && data.text == null
|
||||
? renderAnnounce(data.renote.uri ? data.renote.uri : await renderNote(data.renote))
|
||||
: renderCreate(await renderNote(note));
|
||||
return packAp(content);
|
||||
};
|
||||
|
||||
// 投稿がリプライかつ投稿者がローカルユーザーかつリプライ先の投稿の投稿者がリモートユーザーなら配送
|
||||
if (data.reply && isLocalUser(user) && isRemoteUser(data.reply._user)) {
|
||||
@ -243,6 +245,40 @@ export default async (user: IUser, data: {
|
||||
);
|
||||
}*/
|
||||
|
||||
//#region メンション
|
||||
if (data.text) {
|
||||
// TODO: Drop dupulicates
|
||||
const mentions = tokens
|
||||
.filter(t => t.type == 'mention');
|
||||
|
||||
mentions.forEach(async m => {
|
||||
const u = await resolveUser(m.username, m.host);
|
||||
|
||||
if (isLocalUser(u)) {
|
||||
// Fetch mentioned user
|
||||
const mentionee = await User
|
||||
.findOne({
|
||||
usernameLower: m.username.toLowerCase()
|
||||
}, { _id: true });
|
||||
|
||||
// When mentioned user not found
|
||||
if (mentionee == null) return;
|
||||
|
||||
// 既に言及されたユーザーに対する返信や引用renoteの場合も無視
|
||||
if (data.reply && data.reply.userId.equals(mentionee._id)) return;
|
||||
if (data.renote && data.renote.userId.equals(mentionee._id)) return;
|
||||
|
||||
// Create notification
|
||||
notify(mentionee._id, user._id, 'mention', {
|
||||
noteId: note._id
|
||||
});
|
||||
} else {
|
||||
deliver(user, await render(), u.inbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const mentions = [];
|
||||
|
||||
async function addMention(mentionee, reason) {
|
||||
|
Loading…
Reference in New Issue
Block a user