mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-11 08:32:47 +01:00
Make admin can delete any note
This commit is contained in:
parent
7576569dc9
commit
faf29b768f
2 changed files with 10 additions and 2 deletions
|
@ -33,12 +33,16 @@ export default Vue.extend({
|
||||||
text: '%i18n:@pin%',
|
text: '%i18n:@pin%',
|
||||||
action: this.pin
|
action: this.pin
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin) {
|
||||||
items.push({
|
items.push({
|
||||||
icon: '%fa:trash-alt R%',
|
icon: '%fa:trash-alt R%',
|
||||||
text: '%i18n:@delete%',
|
text: '%i18n:@delete%',
|
||||||
action: this.del
|
action: this.del
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.note.uri) {
|
if (this.note.uri) {
|
||||||
items.push({
|
items.push({
|
||||||
icon: '%fa:external-link-square-alt%',
|
icon: '%fa:external-link-square-alt%',
|
||||||
|
@ -48,6 +52,7 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,14 +21,17 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||||
|
|
||||||
// Fetch note
|
// Fetch note
|
||||||
const note = await Note.findOne({
|
const note = await Note.findOne({
|
||||||
_id: noteId,
|
_id: noteId
|
||||||
userId: user._id
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (note === null) {
|
if (note === null) {
|
||||||
return rej('note not found');
|
return rej('note not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!user.isAdmin && !note.userId.equals(user._id)) {
|
||||||
|
return rej('access denied');
|
||||||
|
}
|
||||||
|
|
||||||
await deleteNote(user, note);
|
await deleteNote(user, note);
|
||||||
|
|
||||||
res();
|
res();
|
||||||
|
|
Loading…
Reference in a new issue