v12 (#5712)
Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
This commit is contained in:
parent
a5955c1123
commit
f6154dc0af
871 changed files with 26140 additions and 71950 deletions
|
@ -17,7 +17,7 @@ import extractMentions from '../../misc/extract-mentions';
|
|||
import extractEmojis from '../../misc/extract-emojis';
|
||||
import extractHashtags from '../../misc/extract-hashtags';
|
||||
import { Note, IMentionedRemoteUsers } from '../../models/entities/note';
|
||||
import { Mutings, Users, NoteWatchings, Notes, Instances, UserProfiles } from '../../models';
|
||||
import { Mutings, Users, NoteWatchings, Notes, Instances, UserProfiles, Antennas, Followings } from '../../models';
|
||||
import { DriveFile } from '../../models/entities/drive-file';
|
||||
import { App } from '../../models/entities/app';
|
||||
import { Not, getConnection, In } from 'typeorm';
|
||||
|
@ -28,6 +28,8 @@ import { Poll, IPoll } from '../../models/entities/poll';
|
|||
import { createNotification } from '../create-notification';
|
||||
import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-error';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { checkHitAntenna } from '../../misc/check-hit-antenna';
|
||||
import { addNoteToAntenna } from '../add-note-to-antenna';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||
|
||||
|
@ -90,7 +92,6 @@ type Option = {
|
|||
reply?: Note | null;
|
||||
renote?: Note | null;
|
||||
files?: DriveFile[] | null;
|
||||
geo?: any | null;
|
||||
poll?: IPoll | null;
|
||||
viaMobile?: boolean | null;
|
||||
localOnly?: boolean | null;
|
||||
|
@ -207,6 +208,23 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
|||
// Increment notes count (user)
|
||||
incNotesCountOfUser(user);
|
||||
|
||||
// Antenna
|
||||
Antennas.find().then(async antennas => {
|
||||
const followings = await Followings.createQueryBuilder('following')
|
||||
.andWhere(`following.followeeId = :userId`, { userId: note.userId })
|
||||
.getMany();
|
||||
|
||||
const followers = followings.map(f => f.followerId);
|
||||
|
||||
for (const antenna of antennas) {
|
||||
checkHitAntenna(antenna, note, user, followers).then(hit => {
|
||||
if (hit) {
|
||||
addNoteToAntenna(antenna, note, user);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (data.reply) {
|
||||
saveReply(data.reply, note);
|
||||
}
|
||||
|
@ -361,8 +379,6 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
|
|||
userId: user.id,
|
||||
viaMobile: data.viaMobile!,
|
||||
localOnly: data.localOnly!,
|
||||
geo: data.geo || null,
|
||||
appId: data.app ? data.app.id : null,
|
||||
visibility: data.visibility as any,
|
||||
visibleUserIds: data.visibility == 'specified'
|
||||
? data.visibleUsers
|
||||
|
|
|
@ -5,7 +5,6 @@ import { deliver } from '../../../queue';
|
|||
import { renderActivity } from '../../../remote/activitypub/renderer';
|
||||
import { IdentifiableError } from '../../../misc/identifiable-error';
|
||||
import { toDbReaction } from '../../../misc/reaction-lib';
|
||||
import { fetchMeta } from '../../../misc/fetch-meta';
|
||||
import { User } from '../../../models/entities/user';
|
||||
import { Note } from '../../../models/entities/note';
|
||||
import { NoteReactions, Users, NoteWatchings, Notes, UserProfiles } from '../../../models';
|
||||
|
@ -22,8 +21,7 @@ export default async (user: User, note: Note, reaction?: string) => {
|
|||
throw new IdentifiableError('2d8e7297-1873-4c00-8404-792c68d7bef0', 'cannot react to my note');
|
||||
}
|
||||
|
||||
const meta = await fetchMeta();
|
||||
reaction = await toDbReaction(reaction, meta.enableEmojiReaction);
|
||||
reaction = await toDbReaction(reaction);
|
||||
|
||||
// Create reaction
|
||||
await NoteReactions.save({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { publishMainStream } from '../stream';
|
||||
import { Note } from '../../models/entities/note';
|
||||
import { User } from '../../models/entities/user';
|
||||
import { NoteUnreads } from '../../models';
|
||||
import { NoteUnreads, Antennas, AntennaNotes, Users } from '../../models';
|
||||
|
||||
/**
|
||||
* Mark a note as read
|
||||
|
@ -17,27 +17,54 @@ export default (
|
|||
});
|
||||
|
||||
// v11 TODO: https://github.com/typeorm/typeorm/issues/2415
|
||||
//if (res.affected == 0) {
|
||||
//if (res.affected === 0) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
const count1 = await NoteUnreads.count({
|
||||
userId: userId,
|
||||
isSpecified: false
|
||||
});
|
||||
const [count1, count2] = await Promise.all([
|
||||
NoteUnreads.count({
|
||||
userId: userId,
|
||||
isSpecified: false
|
||||
}),
|
||||
NoteUnreads.count({
|
||||
userId: userId,
|
||||
isSpecified: true
|
||||
})
|
||||
]);
|
||||
|
||||
const count2 = await NoteUnreads.count({
|
||||
userId: userId,
|
||||
isSpecified: true
|
||||
});
|
||||
|
||||
if (count1 == 0) {
|
||||
if (count1 === 0) {
|
||||
// 全て既読になったイベントを発行
|
||||
publishMainStream(userId, 'readAllUnreadMentions');
|
||||
}
|
||||
|
||||
if (count2 == 0) {
|
||||
if (count2 === 0) {
|
||||
// 全て既読になったイベントを発行
|
||||
publishMainStream(userId, 'readAllUnreadSpecifiedNotes');
|
||||
}
|
||||
|
||||
const antennas = await Antennas.find({ userId });
|
||||
|
||||
await Promise.all(antennas.map(async antenna => {
|
||||
await AntennaNotes.update({
|
||||
antennaId: antenna.id,
|
||||
noteId: noteId
|
||||
}, {
|
||||
read: true
|
||||
});
|
||||
|
||||
const count = await AntennaNotes.count({
|
||||
antennaId: antenna.id,
|
||||
read: false
|
||||
});
|
||||
|
||||
if (count === 0) {
|
||||
publishMainStream(userId, 'readAntenna', antenna);
|
||||
}
|
||||
}));
|
||||
|
||||
Users.getHasUnreadAntenna(userId).then(unread => {
|
||||
if (!unread) {
|
||||
publishMainStream(userId, 'readAllAntennas');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue