reading messages

This commit is contained in:
biglyderv 2025-05-03 13:39:43 -04:00
parent 08fe66906c
commit f44c90647f
Signed by: biglyderv
GPG key ID: 1398543B9746192C
4 changed files with 21 additions and 2 deletions

View file

@ -6,6 +6,16 @@ require(__DIR__ . "/../libs/comment.php");
$ref = 1732684297;
$stmt = $db->prepare("DELETE FROM main.read WHERE username = ?");
$stmt->execute([$username]);
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date");
$stmt->execute(["notification",$username]);
$counter = $stmt->fetchAll(PDO::FETCH_DEFAULT);
$stmt = $db->prepare("INSERT INTO main.read (username, msgs) VALUES (?, ?)");
$stmt->execute([$username, count($counter)]);
page_header();
comments("notification", $username, true);
page_footer();

View file

@ -12,7 +12,15 @@ function page_header()
]);
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
$edge = count($posts2);
$stmt = $db->prepare("SELECT * FROM main.read WHERE username = ?");
$stmt->execute([
$username
]);
$counter = $stmt->fetchAll(PDO::FETCH_DEFAULT);
$edge = count($posts2) - $counter[0]['msgs'];
?>
<!DOCTYPE html>
<html>

View file

@ -4,7 +4,7 @@ require(__DIR__ . "/../libs/test_secret.php");
global $db;
$sql = file_get_contents('../scripts/init.sql', true);
$sql = file_get_contents(__DIR__ .'/../scripts/init.sql', true);
$db->exec($sql);

View file

@ -4,4 +4,5 @@ CREATE TABLE IF NOT EXISTS main.user (username TEXT, bio TEXT);
CREATE TABLE IF NOT EXISTS main.role (username TEXT, role TEXT);
CREATE TABLE IF NOT EXISTS main.follow (username TEXT, target TEXT);
CREATE TABLE IF NOT EXISTS main.ban (username TEXT, reason TEXT);
CREATE TABLE IF NOT EXISTS main.read (username TEXT, msgs REAL);
CREATE TABLE IF NOT EXISTS main.comment (username TEXT, targetType TEXT, targetId TEXT, date REAL, content TEXT, id TEXT);