Merge branch 'master' into develop

This commit is contained in:
Barış Soner Uşaklı
2025-03-05 17:19:52 -05:00
3 changed files with 90 additions and 85 deletions

View File

@@ -94,6 +94,7 @@
"federation.followers-handle": "Handle",
"federation.followers-id": "ID",
"federation.followers-none": "No followers.",
"federation.followers-autofill": "Autofill",
"alert.created": "Created",
"alert.create-success": "Category successfully created!",

View File

@@ -39,25 +39,29 @@ module.exports = function (Topics) {
cid = await posts.getCidByPid(mainPid);
}
const [postData, isAdminOrMod] = await Promise.all([
const [mainPost, isAdminOrMod] = await Promise.all([
posts.getPostData(mainPid),
privileges.categories.isAdminOrMod(cid, uid),
]);
let lastPost = mainPost;
if (pids.length > 1) {
lastPost = await posts.getPostData(pids[pids.length - 1]);
}
if (!isAdminOrMod) {
throw new Error('[[error:no-privileges]]');
}
const scheduled = postData.timestamp > Date.now();
const now = Date.now();
const scheduled = mainPost.timestamp > now;
const params = {
uid: postData.uid,
uid: mainPost.uid,
title: title,
cid: cid,
timestamp: scheduled && postData.timestamp,
timestamp: mainPost.timestamp,
};
const result = await plugins.hooks.fire('filter:topic.fork', {
params: params,
tid: postData.tid,
tid: mainPost.tid,
});
const tid = await Topics.create(result.params);
@@ -72,22 +76,22 @@ module.exports = function (Topics) {
await Topics.movePostToTopic(uid, pid, tid, scheduled);
}
await Topics.updateLastPostTime(tid, scheduled ? (postData.timestamp + 1) : Date.now());
await Topics.updateLastPostTime(tid, scheduled ? (mainPost.timestamp + 1) : lastPost.timestamp);
await Promise.all([
Topics.setTopicFields(tid, {
upvotes: postData.upvotes,
downvotes: postData.downvotes,
upvotes: mainPost.upvotes,
downvotes: mainPost.downvotes,
forkedFromTid: fromTid,
forkerUid: uid,
forkTimestamp: Date.now(),
forkTimestamp: now,
}),
db.sortedSetsAdd(['topics:votes', `cid:${cid}:tids:votes`], postData.votes, tid),
db.sortedSetsAdd(['topics:votes', `cid:${cid}:tids:votes`], mainPost.votes, tid),
Topics.events.log(fromTid, { type: 'fork', uid, href: `/topic/${tid}` }),
activitypub.feps.announceObject(pids[0]),
]);
plugins.hooks.fire('action:topic.fork', { tid: tid, fromTid: fromTid, uid: uid });
plugins.hooks.fire('action:topic.fork', { tid, fromTid, uid });
return await Topics.getTopicData(tid);
};

View File

@@ -14,85 +14,85 @@
<a class="btn btn-primary" href="{config.relative_path}/admin/settings/activitypub">[[admin/manage/categories:federation.disabled-cta]]</a>
</div>
{{{ else }}}
<div class="acp-page-container">
<div class="row settings m-0">
<div class="col-12 col-md-8 px-0 mb-4" tabindex="0">
<div id="site-settings" class="mb-4">
<form role="form">
<h5 class="fw-bold settings-header">[[admin/manage/categories:federation.syncing-header]]</h5>
<p>[[admin/manage/categories:federation.syncing-intro]]</p>
<p class="form-text">[[admin/manage/categories:federation.syncing-caveat]]</p>
<div class="row settings m-0">
<div class="col-12 px-0 mb-4" tabindex="0">
<div id="site-settings" class="mb-4">
<form role="form">
<h5 class="fw-bold settings-header">[[admin/manage/categories:federation.syncing-header]]</h5>
<p>[[admin/manage/categories:federation.syncing-intro]]</p>
<p class="form-text">[[admin/manage/categories:federation.syncing-caveat]]</p>
{{{ if !following.length }}}
<div class="alert alert-info">[[admin/manage/categories:federation.syncing-none]]</div>
{{{ else }}}
<table class="table">
<thead>
<tr>
<th>[[admin/manage/categories:federation.syncing-actorUri]]</th>
<th></th>
</tr>
</thead>
<tbody>
{{{ each following }}}
<tr>
<td>
<pre class="mb-0 mt-1">{./id}</pre>
{{{ if !./approved }}}
<span class="form-text text-warning">Pending</span>
{{{ end }}}
</td>
<td>
<button type="button" data-action="unfollow" data-actor="{./id}" class="btn btn-sm btn-danger">[[admin/manage/categories:federation.syncing-unfollow]]</button>
</td>
</tr>
{{{ end }}}
</tbody>
</table>
{{{ end }}}
{{{ if !following.length }}}
<div class="alert alert-info">[[admin/manage/categories:federation.syncing-none]]</div>
{{{ else }}}
<table class="table">
<thead>
<tr>
<th>[[admin/manage/categories:federation.syncing-actorUri]]</th>
<th></th>
</tr>
</thead>
<tbody>
{{{ each following }}}
<tr>
<td>
<pre class="mb-0 mt-1">{./id}</pre>
{{{ if !./approved }}}
<span class="form-text text-warning">Pending</span>
{{{ end }}}
</td>
<td>
<button type="button" data-action="unfollow" data-actor="{./id}" class="btn btn-sm btn-danger">[[admin/manage/categories:federation.syncing-unfollow]]</button>
</td>
</tr>
{{{ end }}}
</tbody>
</table>
{{{ end }}}
<div class="mb-3">
<label class="form-label" for="syncing-add">[[admin/manage/categories:federation.syncing-add]]</label>
<div class="input-group">
<input id="syncing-add" type="url" class="form-control" />
<button data-action="follow" type="button" class="btn btn-primary">[[admin/manage/categories:federation.syncing-follow]]</button>
</div>
<div class="mb-3">
<label class="form-label" for="syncing-add">[[admin/manage/categories:federation.syncing-add]]</label>
<div class="input-group">
<input id="syncing-add" type="url" class="form-control" />
<button data-action="follow" type="button" class="btn btn-primary">[[admin/manage/categories:federation.syncing-follow]]</button>
</div>
</div>
<hr />
<hr />
<div class="mb-3">
<p>[[admin/manage/categories:federation.followers]]</p>
<table class="table small">
<tr>
<th>[[admin/manage/categories:federation.followers-handle]]</th>
<th>[[admin/manage/categories:federation.followers-id]]</th>
</tr>
{{{ if !followers.length}}}
<tr>
<td class="text-center border-0" colspan="2">
<em>[[admin/manage/categories:federation.followers-none]]</em>
</td>
</tr>
{{{ end }}}
{{{ each followers }}}
<tr data-uid="{./uid}">
<td>
{buildAvatar(followers, "24px", true)}
{./userslug}
</td>
<td>
<code>{./uid}</code>
<button type="button" class="btn btn-link" data-action="autofill">
<i class="fa fa-exchange-alt"></i>
<div class="mb-3">
<p>[[admin/manage/categories:federation.followers]]</p>
<table class="table small">
<tr>
<th>[[admin/manage/categories:federation.followers-handle]]</th>
<th>[[admin/manage/categories:federation.followers-id]]</th>
</tr>
{{{ if !followers.length}}}
<tr>
<td class="text-center border-0" colspan="2">
<em>[[admin/manage/categories:federation.followers-none]]</em>
</td>
</tr>
{{{ end }}}
{{{ each followers }}}
<tr data-uid="{./uid}">
<td class="w-100 text-truncate" style="max-width: 1px;">
{buildAvatar(followers, "24px", true)}
{./userslug}
</td>
<td class="w-0">
<div class="d-flex gap-2 flex-nowrap align-items-center">
<button type="button" class="btn btn-ghost btn-sm border" data-action="autofill" title="[[admin/manage/categories:federation.followers-autofill]]">
<i class="fa fa-exchange-alt text-primary"></i>
</button>
</td>
</tr>
{{{ end }}}
</table>
</div>
</form>
</div>
<code>{./uid}</code>
</div>
</td>
</tr>
{{{ end }}}
</table>
</div>
</form>
</div>
</div>
</div>