`uid` mediumint unsigned COMMENT 'Owner User id',
`delayed` datetime COMMENT 'delay time',
PRIMARY KEY(`id`),
- UNIQUE INDEX `uri` (`uri`(190)),
+ UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be posted at a later time';
*/
public static function add(string $delayed, array $item, int $notify = 0, array $taglist = [], array $attachments = [])
{
- if (empty($item['uri']) || empty($item['uid']) || self::exists($item['uri'])) {
+ if (empty($item['uri']) || empty($item['uid']) || self::exists($item['uri'], $item['uid'])) {
return false;
}
*
* @return bool delete success
*/
- private static function delete(string $uri)
+ private static function delete(string $uri, int $uid)
{
- return DBA::delete('delayed-post', ['uri' => $uri]);
+ return DBA::delete('delayed-post', ['uri' => $uri, 'uid' => $uid]);
}
/**
*
* @return bool "true" if an entry with that URI exists
*/
- public static function exists(string $uri)
+ public static function exists(string $uri, int $uid)
{
- return DBA::exists('delayed-post', ['uri' => $uri]);
+ return DBA::exists('delayed-post', ['uri' => $uri, 'uid' => $uid]);
}
/**
// It should always contain an URI since this is needed to create a delayed post entry
if (!empty($item['uri'])) {
- $result = self::delete($item['uri']);
+ $result = self::delete($item['uri'], $item['uid']);
Logger::notice('Delayed post entry deleted', ['result' => $result, 'uri' => $item['uri']]);
}
}
$condition = ['uid' => $item['uid'], 'uri' => $item['uri']];
- if (!Item::exists($condition) && !Post\Delayed::exists($item["uri"])) {
+ if (!Item::exists($condition) && !Post\Delayed::exists($item["uri"], $item['uid'])) {
$postings[] = ['item' => $item, 'notify' => $notify,
'taglist' => $taglist, 'attachments' => $attachments];
} else {