mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 00:36:42 -06:00
Fix bug
This commit is contained in:
parent
dfb6e717e4
commit
02fd46f64f
3 changed files with 6 additions and 7 deletions
|
@ -47,7 +47,8 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
|
||||||
const object = await resolver.resolve(value) as any;
|
const object = await resolver.resolve(value) as any;
|
||||||
|
|
||||||
if (object == null || object.type !== 'Note') {
|
if (object == null || object.type !== 'Note') {
|
||||||
throw new Error('invalid note');
|
log(`invalid note: ${object}`);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const note: INoteActivityStreamsObject = object;
|
const note: INoteActivityStreamsObject = object;
|
||||||
|
@ -62,7 +63,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
|
||||||
if (!note.to.includes('https://www.w3.org/ns/activitystreams#Public')) visibility = 'unlisted';
|
if (!note.to.includes('https://www.w3.org/ns/activitystreams#Public')) visibility = 'unlisted';
|
||||||
if (note.cc.length == 0) visibility = 'private';
|
if (note.cc.length == 0) visibility = 'private';
|
||||||
// TODO
|
// TODO
|
||||||
if (visibility != 'public') throw new Error('unspported visibility');
|
if (visibility != 'public') return null;
|
||||||
//#endergion
|
//#endergion
|
||||||
|
|
||||||
// 添付メディア
|
// 添付メディア
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { MongoError } from 'mongodb';
|
|
||||||
import Note, { pack, INote } from '../../models/note';
|
import Note, { pack, INote } from '../../models/note';
|
||||||
import User, { isLocalUser, IUser, isRemoteUser } from '../../models/user';
|
import User, { isLocalUser, IUser, isRemoteUser } from '../../models/user';
|
||||||
import stream, { publishLocalTimelineStream, publishGlobalTimelineStream } from '../../publishers/stream';
|
import stream, { publishLocalTimelineStream, publishGlobalTimelineStream } from '../../publishers/stream';
|
||||||
|
@ -91,7 +90,7 @@ export default async (user: IUser, data: {
|
||||||
note = await Note.insert(insert);
|
note = await Note.insert(insert);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// duplicate key error
|
// duplicate key error
|
||||||
if (e instanceof MongoError && e.code === 11000) {
|
if (e.code === 11000) {
|
||||||
return res(null);
|
return res(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import watch from '../watch';
|
||||||
import renderLike from '../../../remote/activitypub/renderer/like';
|
import renderLike from '../../../remote/activitypub/renderer/like';
|
||||||
import { deliver } from '../../../queue';
|
import { deliver } from '../../../queue';
|
||||||
import pack from '../../../remote/activitypub/renderer';
|
import pack from '../../../remote/activitypub/renderer';
|
||||||
import { MongoError } from 'mongodb';
|
|
||||||
|
|
||||||
export default async (user: IUser, note: INote, reaction: string) => new Promise(async (res, rej) => {
|
export default async (user: IUser, note: INote, reaction: string) => new Promise(async (res, rej) => {
|
||||||
// Myself
|
// Myself
|
||||||
|
@ -27,8 +26,8 @@ export default async (user: IUser, note: INote, reaction: string) => new Promise
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// duplicate key error
|
// duplicate key error
|
||||||
if (e instanceof MongoError && e.code === 11000) {
|
if (e.code === 11000) {
|
||||||
return rej('already reacted');
|
return res(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
Loading…
Reference in a new issue