自分のノートにリアクションを押せるように (#6506)

* resolve #6468

* リモートから来たセルフリアクションの対応
This commit is contained in:
Xeltica 2020-07-30 20:28:35 +09:00 committed by GitHub
parent f5d43b1f25
commit 71878f93e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 20 deletions

View file

@ -71,10 +71,10 @@
<button v-else class="button _button"> <button v-else class="button _button">
<fa :icon="faBan"/> <fa :icon="faBan"/>
</button> </button>
<button v-if="!isMyNote && appearNote.myReaction == null" class="button _button" @click="react()" ref="reactButton"> <button v-if="appearNote.myReaction == null" class="button _button" @click="react()" ref="reactButton">
<fa :icon="faPlus"/> <fa :icon="faPlus"/>
</button> </button>
<button v-if="!isMyNote && appearNote.myReaction != null" class="button _button reacted" @click="undoReact(appearNote)" ref="reactButton"> <button v-if="appearNote.myReaction != null" class="button _button reacted" @click="undoReact(appearNote)" ref="reactButton">
<fa :icon="faMinus"/> <fa :icon="faMinus"/>
</button> </button>
<button class="button _button" @click="menu()" ref="menuButton"> <button class="button _button" @click="menu()" ref="menuButton">

View file

@ -51,11 +51,8 @@ export default Vue.extend({
}; };
}, },
computed: { computed: {
isMe(): boolean {
return this.$store.getters.isSignedIn && this.$store.state.i.id === this.note.userId;
},
canToggle(): boolean { canToggle(): boolean {
return !this.reaction.match(/@\w/) && !this.isMe && this.$store.getters.isSignedIn; return !this.reaction.match(/@\w/) && this.$store.getters.isSignedIn;
}, },
}, },
watch: { watch: {

View file

@ -9,8 +9,6 @@ export default async (actor: IRemoteUser, activity: ILike) => {
const note = await fetchNote(targetUri); const note = await fetchNote(targetUri);
if (!note) return `skip: target note not found ${targetUri}`; if (!note) return `skip: target note not found ${targetUri}`;
if (actor.id === note.userId) return `skip: cannot react to my note`;
await extractEmojis(activity.tag || [], actor.host).catch(() => null); await extractEmojis(activity.tag || [], actor.host).catch(() => null);
await create(actor, note, activity._misskey_reaction || activity.content || activity.name); await create(actor, note, activity._misskey_reaction || activity.content || activity.name);

View file

@ -40,12 +40,6 @@ export const meta = {
id: '033d0620-5bfe-4027-965d-980b0c85a3ea' id: '033d0620-5bfe-4027-965d-980b0c85a3ea'
}, },
isMyNote: {
message: 'You can not react to your own notes.',
code: 'IS_MY_NOTE',
id: '7eeb9714-b047-43b5-b559-7b1b72810f53'
},
alreadyReacted: { alreadyReacted: {
message: 'You are already reacting to that note.', message: 'You are already reacting to that note.',
code: 'ALREADY_REACTED', code: 'ALREADY_REACTED',
@ -60,7 +54,6 @@ export default define(meta, async (ps, user) => {
throw e; throw e;
}); });
await createReaction(user, note, ps.reaction).catch(e => { await createReaction(user, note, ps.reaction).catch(e => {
if (e.id === '2d8e7297-1873-4c00-8404-792c68d7bef0') throw new ApiError(meta.errors.isMyNote);
if (e.id === '51c42bb4-931a-456b-bff7-e5a8a70dd298') throw new ApiError(meta.errors.alreadyReacted); if (e.id === '51c42bb4-931a-456b-bff7-e5a8a70dd298') throw new ApiError(meta.errors.alreadyReacted);
throw e; throw e;
}); });

View file

@ -15,11 +15,6 @@ import { createNotification } from '../../create-notification';
import deleteReaction from './delete'; import deleteReaction from './delete';
export default async (user: User, note: Note, reaction?: string) => { export default async (user: User, note: Note, reaction?: string) => {
// Myself
if (note.userId === user.id) {
throw new IdentifiableError('2d8e7297-1873-4c00-8404-792c68d7bef0', 'cannot react to my note');
}
reaction = await toDbReaction(reaction, user.host); reaction = await toDbReaction(reaction, user.host);
const exist = await NoteReactions.findOne({ const exist = await NoteReactions.findOne({