Prevent posting the same message twice, if no other message was posted in-between

This commit is contained in:
Daniel Winzen
2016-07-30 16:45:01 +02:00
parent 2951780599
commit 2b8faa735a
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,7 @@
Don't display empty option for system messages in delete messages by name
Don't show a kick button on your own session in the list of active sessions
Allow ignoring incognito chatters
Prevent posting the same message twice, if no other message was posted in-between
Version 1.20.6 - Jul. 23, 2016
Simplify ignore logic + disallow ignoring chatters with higher status

View File

@ -2911,11 +2911,11 @@ function create_hotlinks(){
}
function add_message(){
global $U;
global $U, $db;
if(empty($U['message'])){
return false;
}
$newmessage=array(
$message=array(
'postdate' =>time(),
'poststatus' =>$U['poststatus'],
'poster' =>$U['nickname'],
@ -2923,7 +2923,13 @@ function add_message(){
'text' =>"<span class=\"usermsg\">$U[displaysend]".style_this($U['message'], $U['style']).'</span>',
'delstatus' =>$U['status']
);
write_message($newmessage);
//prevent posting the same message twice, if no other message was posted in-between.
$stmt=$db->prepare('SELECT id FROM ' . PREFIX . 'messages WHERE poststatus=? AND poster=? AND recipient=? AND text=? AND id IN (SELECT * FROM (SELECT id FROM ' . PREFIX . 'messages ORDER BY id DESC LIMIT 1) AS t);');
$stmt->execute([$message['poststatus'], $message['poster'], $message['recipient'], $message['text']]);
if($stmt->fetch(PDO::FETCH_NUM)){
return false;
}
write_message($message);
return true;
}