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:
Barış Uşaklı
2026-01-11 14:38:14 -05:00
committed by GitHub
parent 74e478200f
commit 7b793527f9
15 changed files with 159 additions and 31 deletions

View File

@@ -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);
};