Gave posts a 1 minute cooldown for edits without being marked as edited.

This commit is contained in:
flash 2023-03-11 22:28:10 +00:00
parent d05046ff1f
commit d54528f8ea
2 changed files with 9 additions and 1 deletions

View file

@ -219,7 +219,12 @@ if(!empty($_POST)) {
break;
case 'edit':
if(!forum_post_update($postId, $_SERVER['REMOTE_ADDR'], $postText, $postParser, $postSignature, $postText !== $post['post_text'])) {
$markUpdated = $post['poster_id'] === $currentUserId
&& $post['post_created_unix'] < strtotime('-1 minutes')
&& $postText !== $post['post_text'];
if(!forum_post_update($postId, $_SERVER['REMOTE_ADDR'], $postText, $postParser, $postSignature, $markUpdated)) {
$notices[] = 'Post edit failed.';
}

View file

@ -87,6 +87,8 @@ function forum_post_find(int $postId, int $userId): array {
}
function forum_post_get(int $postId, bool $allowDeleted = false): array {
// i have no idea if the post_created field depend on not being parsed, so post_created_unix it is!
// not even the first time i've done this either (see forum_latest_post) lol, what a mess
$getPost = \Misuzu\DB::prepare(sprintf(
'
SELECT
@ -95,6 +97,7 @@ function forum_post_get(int $postId, bool $allowDeleted = false): array {
INET6_NTOA(p.`post_ip`) AS `post_ip`,
u.`user_id` AS `poster_id`, u.`username` AS `poster_name`,
u.`user_created` AS `poster_joined`, u.`user_country` AS `poster_country`,
UNIX_TIMESTAMP(p.`post_created`) AS `post_created_unix`,
COALESCE(u.`user_colour`, r.`role_colour`) AS `poster_colour`,
(
SELECT COUNT(`post_id`)