mirror of
https://github.com/friendica/friendica
synced 2025-04-26 10:30:11 +00:00
Use a centralized function to delete delayed entries
This commit is contained in:
parent
5a2fa2f81a
commit
6c8a4a2552
3 changed files with 28 additions and 25 deletions
|
@ -44,7 +44,7 @@ class Delayed
|
|||
* @param array $taglist
|
||||
* @param array $attachments
|
||||
* @return int ID of the created delayed post entry
|
||||
*/
|
||||
*/
|
||||
public static function add(string $uri, array $item, int $notify = 0, bool $unprepared = false, string $delayed = '', array $taglist = [], array $attachments = [])
|
||||
{
|
||||
if (empty($item['uid']) || self::exists($uri, $item['uid'])) {
|
||||
|
@ -98,6 +98,23 @@ class Delayed
|
|||
return DBA::delete('delayed-post', ['uri' => $uri, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete scheduled posts and the associated workerqueue entry
|
||||
*
|
||||
* @param integer $id
|
||||
* @return void
|
||||
*/
|
||||
public static function deleteById(int $id)
|
||||
{
|
||||
$post = DBA::selectFirst('delayed-post', ['wid'], ['id' => $id]);
|
||||
if (empty($post['wid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
DBA::delete('delayed-post', ['id' => $id]);
|
||||
DBA::delete('workerqueue', ['id' => $post['wid']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an entry exists
|
||||
*
|
||||
|
@ -192,7 +209,7 @@ class Delayed
|
|||
if (self::exists($uri, $item['uid'])) {
|
||||
self::delete($uri, $item['uid']);
|
||||
}
|
||||
|
||||
|
||||
return $id;
|
||||
}
|
||||
$id = Item::insert($item, $notify);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue