mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-28 22:49:50 +02:00
Change owner rest route (#13881)
* fix: dont use sass-embedded on freebsd, #13867 * fix: #13715, dont reduce hardcap if usersPerPage is < 50 * fix: closes #13872, use translator.compile for notification text so commas don't cause issues * fix: remove bidiControls from notification.bodyShort * refactor: move change owner call to rest api deprecate socket method * fix spec * test: one more fix * test: add 404 * test: fix tests :rage1: * test: update test to use new method
This commit is contained in:
@@ -665,3 +665,26 @@ async function sendQueueNotification(type, targetUid, path, notificationText) {
|
||||
const notifObj = await notifications.create(notifData);
|
||||
await notifications.push(notifObj, [targetUid]);
|
||||
}
|
||||
|
||||
postsAPI.changeOwner = async function (caller, data) {
|
||||
if (!data || !Array.isArray(data.pids) || !data.uid) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
const isAdminOrGlobalMod = await user.isAdminOrGlobalMod(caller.uid);
|
||||
if (!isAdminOrGlobalMod) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
|
||||
const postData = await posts.changeOwner(data.pids, data.uid);
|
||||
const logs = postData.map(({ pid, uid, cid }) => (events.log({
|
||||
type: 'post-change-owner',
|
||||
uid: caller.uid,
|
||||
ip: caller.ip,
|
||||
targetUid: data.uid,
|
||||
pid: pid,
|
||||
originalUid: uid,
|
||||
cid: cid,
|
||||
})));
|
||||
|
||||
await Promise.all(logs);
|
||||
};
|
||||
Reference in New Issue
Block a user