forked from friendica/friendica-addons
Use the Item class instead of DBA calls when possible (#705)
This commit is contained in:
parent
fd1eed17ab
commit
28b699573c
|
@ -955,7 +955,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
|
|||
}
|
||||
|
||||
$condition = ['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']];
|
||||
if (DBA::exists('item', $condition)) {
|
||||
if (Item::exists($condition)) {
|
||||
logger("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
||||
return;
|
||||
}
|
||||
|
@ -1084,13 +1084,13 @@ function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
|
|||
{
|
||||
// Two queries for speed issues
|
||||
$condition = ['uri' => $post->object->id, 'uid' => $uid];
|
||||
if (DBA::exists('item', $condition)) {
|
||||
if (Item::exists($condition)) {
|
||||
Item::delete($condition);
|
||||
return true;
|
||||
}
|
||||
|
||||
$condition = ['extid' => $post->object->id, 'uid' => $uid];
|
||||
if (DBA::exists('item', $condition)) {
|
||||
if (Item::exists($condition)) {
|
||||
Item::delete($condition);
|
||||
return true;
|
||||
}
|
||||
|
@ -1115,10 +1115,10 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
|
|||
|
||||
if ($post->verb != "update") {
|
||||
// Two queries for speed issues
|
||||
if (DBA::exists('item', ['uri' => $post->object->id, 'uid' => $uid])) {
|
||||
if (Item::exists(['uri' => $post->object->id, 'uid' => $uid])) {
|
||||
return false;
|
||||
}
|
||||
if (DBA::exists('item', ['extid' => $post->object->id, 'uid' => $uid])) {
|
||||
if (Item::exists(['extid' => $post->object->id, 'uid' => $uid])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1659,11 +1659,11 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
|
|||
}
|
||||
|
||||
// Checking if the comment already exists - Two queries for speed issues
|
||||
if (DBA::exists('item', ['uri' => $item->id, 'uid' => $uid])) {
|
||||
if (Item::exists(['uri' => $item->id, 'uid' => $uid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DBA::exists('item', ['extid' => $item->id, 'uid' => $uid])) {
|
||||
if (Item::exists(['extid' => $item->id, 'uid' => $uid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1079,7 +1079,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
|
|||
|
||||
$postarray['uri'] = $hostname . "::" . $content->id;
|
||||
|
||||
if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
|
||||
if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -735,15 +735,9 @@ function twitter_expire(App $a)
|
|||
return;
|
||||
}
|
||||
|
||||
$r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => Protocol::TWITTER]);
|
||||
$r = Item::select(['id'], ['deleted' => true, 'network' => Protocol::TWITTER]);
|
||||
while ($row = DBA::fetch($r)) {
|
||||
DBA::delete('item', ['id' => $row['id']]);
|
||||
if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) {
|
||||
DBA::delete('item-activity', ['id' => $row['iaid']]);
|
||||
}
|
||||
if (!empty($row['icid']) && !DBA::exists('item', ['icid' => $row['icid']])) {
|
||||
DBA::delete('item-content', ['id' => $row['icid']]);
|
||||
}
|
||||
}
|
||||
DBA::close($r);
|
||||
|
||||
|
@ -1352,7 +1346,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
|
|||
$postarray['source'] = json_encode($post);
|
||||
|
||||
// Don't import our own comments
|
||||
if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
|
||||
if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) {
|
||||
logger("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG);
|
||||
return [];
|
||||
}
|
||||
|
@ -1530,7 +1524,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection,
|
|||
break;
|
||||
}
|
||||
|
||||
if (DBA::exists('item', ['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) {
|
||||
if (Item::exists(['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue