mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
Fix NoteReaction (#4547)
This commit is contained in:
parent
0f8246705b
commit
2efb187466
4 changed files with 9 additions and 10 deletions
|
@ -2,7 +2,6 @@ import * as mongo from 'mongodb';
|
|||
import * as deepcopy from 'deepcopy';
|
||||
import db from '../db/mongodb';
|
||||
import isObjectId from '../misc/is-objectid';
|
||||
import Reaction from './note-reaction';
|
||||
import { pack as packUser } from './user';
|
||||
|
||||
const NoteReaction = db.get<INoteReaction>('noteReactions');
|
||||
|
@ -30,11 +29,11 @@ export const pack = (
|
|||
|
||||
// Populate the reaction if 'reaction' is ID
|
||||
if (isObjectId(reaction)) {
|
||||
_reaction = await Reaction.findOne({
|
||||
_reaction = await NoteReaction.findOne({
|
||||
_id: reaction
|
||||
});
|
||||
} else if (typeof reaction === 'string') {
|
||||
_reaction = await Reaction.findOne({
|
||||
_reaction = await NoteReaction.findOne({
|
||||
_id: new mongo.ObjectID(reaction)
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { length } from 'stringz';
|
|||
import { IUser, pack as packUser } from './user';
|
||||
import { pack as packApp } from './app';
|
||||
import PollVote from './poll-vote';
|
||||
import Reaction from './note-reaction';
|
||||
import NoteReaction from './note-reaction';
|
||||
import { packMany as packFileMany, IDriveFile } from './drive-file';
|
||||
import Following from './following';
|
||||
import Emoji from './emoji';
|
||||
|
@ -357,7 +357,7 @@ export const pack = async (
|
|||
if (meId) {
|
||||
// Fetch my reaction
|
||||
_note.myReaction = (async () => {
|
||||
const reaction = await Reaction
|
||||
const reaction = await NoteReaction
|
||||
.findOne({
|
||||
userId: meId,
|
||||
noteId: id,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import $ from 'cafy';
|
||||
import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Reaction, { pack } from '../../../../models/note-reaction';
|
||||
import NoteReaction, { pack } from '../../../../models/note-reaction';
|
||||
import define from '../../define';
|
||||
import { getNote } from '../../common/getters';
|
||||
import { ApiError } from '../../error';
|
||||
|
@ -87,7 +87,7 @@ export default define(meta, async (ps, user) => {
|
|||
};
|
||||
}
|
||||
|
||||
const reactions = await Reaction.find(query, {
|
||||
const reactions = await NoteReaction.find(query, {
|
||||
limit: ps.limit,
|
||||
skip: ps.offset,
|
||||
sort: sort
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { IUser, isLocalUser, isRemoteUser } from '../../../models/user';
|
||||
import Note, { INote } from '../../../models/note';
|
||||
import Reaction from '../../../models/note-reaction';
|
||||
import NoteReaction from '../../../models/note-reaction';
|
||||
import { publishNoteStream } from '../../stream';
|
||||
import renderLike from '../../../remote/activitypub/renderer/like';
|
||||
import renderUndo from '../../../remote/activitypub/renderer/undo';
|
||||
|
@ -10,7 +10,7 @@ import { IdentifiableError } from '../../../misc/identifiable-error';
|
|||
|
||||
export default async (user: IUser, note: INote) => {
|
||||
// if already unreacted
|
||||
const exist = await Reaction.findOne({
|
||||
const exist = await NoteReaction.findOne({
|
||||
noteId: note._id,
|
||||
userId: user._id,
|
||||
deletedAt: { $exists: false }
|
||||
|
@ -21,7 +21,7 @@ export default async (user: IUser, note: INote) => {
|
|||
}
|
||||
|
||||
// Delete reaction
|
||||
await Reaction.remove({
|
||||
await NoteReaction.remove({
|
||||
_id: exist._id
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue