Skip to content

Commit

Permalink
Fix multi-user bug
Browse files Browse the repository at this point in the history
  • Loading branch information
powerivq committed Apr 22, 2020
1 parent dcc123b commit d9b5722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions php/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,20 @@ function get_excerpt_img($html) {

function has_pushed($link) {
$sha1 = sha1($link);
$uid = $this->plugin_host->get_owner_uid();
$find_stmt = $this->plugin_host->get_pdo()->prepare('SELECT EXISTS(
SELECT * FROM ttrss_pusher WHERE url_hash=?)');
$find_stmt->execute([$sha1]);
SELECT * FROM ttrss_pusher WHERE uid=? AND url_hash=?)');
$find_stmt->execute([$uid, $sha1]);
$result = $find_stmt->fetch();
if ($result[0]) {
$this->plugin_host->get_pdo()->prepare('UPDATE ttrss_pusher
SET last_accessed=NOW() WHERE url_hash=?')->execute([$sha1]);
SET last_accessed=NOW() WHERE uid=? AND url_hash=?')
->execute([$uid, $sha1]);
return true;
}
$this->plugin_host->get_pdo()->prepare('INSERT INTO ttrss_pusher
(url_hash, last_accessed) VALUES (?, NOW())')->execute([$sha1]);
(url_hash, last_accessed, uid) VALUES (?, NOW(), ?)')
->execute([$sha1, $uid]);
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion php/init.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CREATE TABLE IF NOT EXISTS `ttrss_pusher` (
url_hash VARCHAR(40) PRIMARY KEY,
last_accessed TIMESTAMP NOT NULL
last_accessed TIMESTAMP NOT NULL,
uid INT
);

0 comments on commit d9b5722

Please sign in to comment.