Merge pull request #5294 from annando/use-gravity
Use gravity instead of verb
This commit is contained in:
commit
1e9bff88bc
17 changed files with 136 additions and 109 deletions
5
boot.php
5
boot.php
|
@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
|
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
|
||||||
define('FRIENDICA_VERSION', '2018.08-dev');
|
define('FRIENDICA_VERSION', '2018.08-dev');
|
||||||
define('DFRN_PROTOCOL_VERSION', '2.23');
|
define('DFRN_PROTOCOL_VERSION', '2.23');
|
||||||
define('DB_UPDATE_VERSION', 1271);
|
define('DB_UPDATE_VERSION', 1272);
|
||||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -451,8 +451,9 @@ define('ACTIVITY_OBJ_QUESTION', 'http://activityschema.org/object/question');
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
define('GRAVITY_PARENT', 0);
|
define('GRAVITY_PARENT', 0);
|
||||||
define('GRAVITY_LIKE', 3);
|
define('GRAVITY_ACTIVITY', 3);
|
||||||
define('GRAVITY_COMMENT', 6);
|
define('GRAVITY_COMMENT', 6);
|
||||||
|
define('GRAVITY_UNKNOWN', 9);
|
||||||
/* @}*/
|
/* @}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2018.08-dev (The Tazmans Flax-lily)
|
-- Friendica 2018.08-dev (The Tazmans Flax-lily)
|
||||||
-- DB_UPDATE_VERSION 1271
|
-- DB_UPDATE_VERSION 1272
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,6 +565,7 @@ CREATE TABLE IF NOT EXISTS `item-content` (
|
||||||
`target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
|
`target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
|
||||||
`target` text COMMENT 'JSON encoded target structure if used',
|
`target` text COMMENT 'JSON encoded target structure if used',
|
||||||
`plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
|
`plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
|
||||||
|
`verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
|
||||||
PRIMARY KEY(`id`),
|
PRIMARY KEY(`id`),
|
||||||
UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
|
UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
|
||||||
INDEX `uri` (`uri`(191))
|
INDEX `uri` (`uri`(191))
|
||||||
|
|
|
@ -1270,8 +1270,8 @@ function api_status_show($type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get last public wall message
|
// get last public wall message
|
||||||
$condition = ["`owner-id` = ? AND `uid` = ? AND `type` != 'activity' ".$privacy_sql,
|
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
|
||||||
$user_info['pid'], api_user()];
|
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
||||||
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
|
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
|
||||||
|
|
||||||
if (DBM::is_result($lastwall)) {
|
if (DBM::is_result($lastwall)) {
|
||||||
|
@ -1355,8 +1355,8 @@ function api_users_show($type)
|
||||||
|
|
||||||
$user_info = api_get_user($a);
|
$user_info = api_get_user($a);
|
||||||
|
|
||||||
$condition = ["`owner-id` = ? AND `uid` = ? AND `verb` = ? AND `type` != 'activity' AND NOT `private`",
|
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
|
||||||
$user_info['pid'], api_user(), ACTIVITY_POST];
|
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => false];
|
||||||
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
|
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
|
||||||
|
|
||||||
if (DBM::is_result($lastwall)) {
|
if (DBM::is_result($lastwall)) {
|
||||||
|
@ -1534,10 +1534,10 @@ function api_search($type)
|
||||||
|
|
||||||
$start = $page * $count;
|
$start = $page * $count;
|
||||||
|
|
||||||
$condition = ["`verb` = ? AND `item`.`id` > ?
|
$condition = ["`gravity` IN (?, ?) AND `item`.`id` > ?
|
||||||
AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
|
AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
|
||||||
AND `item`.`body` LIKE CONCAT('%',?,'%')",
|
AND `item`.`body` LIKE CONCAT('%',?,'%')",
|
||||||
ACTIVITY_POST, $since_id, api_user(), $_REQUEST['q']];
|
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, api_user(), $_REQUEST['q']];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `item`.`id` <= ?";
|
$condition[0] .= " AND `item`.`id` <= ?";
|
||||||
|
@ -1597,7 +1597,8 @@ function api_statuses_home_timeline($type)
|
||||||
|
|
||||||
$start = $page * $count;
|
$start = $page * $count;
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ?", api_user(), ACTIVITY_POST, $since_id];
|
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `item`.`id` > ?",
|
||||||
|
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `item`.`id` <= ?";
|
$condition[0] .= " AND `item`.`id` <= ?";
|
||||||
|
@ -1625,7 +1626,7 @@ function api_statuses_home_timeline($type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($idarray)) {
|
if (!empty($idarray)) {
|
||||||
$unseen = dba::exists('item', ['unseen' => true, 'id' => $idarray]);
|
$unseen = Item::exists(['unseen' => true, 'id' => $idarray]);
|
||||||
if ($unseen) {
|
if ($unseen) {
|
||||||
Item::update(['unseen' => false], ['unseen' => true, 'id' => $idarray]);
|
Item::update(['unseen' => false], ['unseen' => true, 'id' => $idarray]);
|
||||||
}
|
}
|
||||||
|
@ -1680,8 +1681,8 @@ function api_statuses_public_timeline($type)
|
||||||
$sql_extra = '';
|
$sql_extra = '';
|
||||||
|
|
||||||
if ($exclude_replies && !$conversation_id) {
|
if ($exclude_replies && !$conversation_id) {
|
||||||
$condition = ["`verb` = ? AND `iid` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall`",
|
$condition = ["`gravity` IN (?, ?) AND `iid` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall`",
|
||||||
ACTIVITY_POST, $since_id];
|
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `thread`.`iid` <= ?";
|
$condition[0] .= " AND `thread`.`iid` <= ?";
|
||||||
|
@ -1693,8 +1694,8 @@ function api_statuses_public_timeline($type)
|
||||||
|
|
||||||
$r = Item::inArray($statuses);
|
$r = Item::inArray($statuses);
|
||||||
} else {
|
} else {
|
||||||
$condition = ["`verb` = ? AND `id` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall` AND `item`.`origin`",
|
$condition = ["`gravity` IN (?, ?) AND `id` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall` AND `item`.`origin`",
|
||||||
ACTIVITY_POST, $since_id];
|
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `item`.`id` <= ?";
|
$condition[0] .= " AND `item`.`id` <= ?";
|
||||||
|
@ -1756,8 +1757,8 @@ function api_statuses_networkpublic_timeline($type)
|
||||||
}
|
}
|
||||||
$start = ($page - 1) * $count;
|
$start = ($page - 1) * $count;
|
||||||
|
|
||||||
$condition = ["`uid` = 0 AND `verb` = ? AND `thread`.`iid` > ? AND NOT `private`",
|
$condition = ["`uid` = 0 AND `gravity` IN (?, ?) AND `thread`.`iid` > ? AND NOT `private`",
|
||||||
ACTIVITY_POST, $since_id];
|
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `thread`.`iid` <= ?";
|
$condition[0] .= " AND `thread`.`iid` <= ?";
|
||||||
|
@ -1829,10 +1830,10 @@ function api_statuses_show($type)
|
||||||
$id = $item['id'];
|
$id = $item['id'];
|
||||||
|
|
||||||
if ($conversation) {
|
if ($conversation) {
|
||||||
$condition = ['parent' => $id, 'verb' => ACTIVITY_POST];
|
$condition = ['parent' => $id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
||||||
$params = ['order' => ['id' => true]];
|
$params = ['order' => ['id' => true]];
|
||||||
} else {
|
} else {
|
||||||
$condition = ['id' => $id, 'verb' => ACTIVITY_POST];
|
$condition = ['id' => $id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
||||||
$params = [];
|
$params = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1908,8 +1909,8 @@ function api_conversation_show($type)
|
||||||
|
|
||||||
$id = $parent['id'];
|
$id = $parent['id'];
|
||||||
|
|
||||||
$condition = ["`parent` = ? AND `uid` IN (0, ?) AND `verb` = ? AND `item`.`id` > ?",
|
$condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `item`.`id` > ?",
|
||||||
$id, api_user(), ACTIVITY_POST, $since_id];
|
$id, api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `item`.`id` <= ?";
|
$condition[0] .= " AND `item`.`id` <= ?";
|
||||||
|
@ -2077,9 +2078,9 @@ function api_statuses_mentions($type)
|
||||||
|
|
||||||
$start = ($page - 1) * $count;
|
$start = ($page - 1) * $count;
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ? AND `author-id` != ?
|
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `item`.`id` > ? AND `author-id` != ?
|
||||||
AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `thread`.`uid` = ? AND `thread`.`mention` AND NOT `thread`.`ignored`)",
|
AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `thread`.`uid` = ? AND `thread`.`mention` AND NOT `thread`.`ignored`)",
|
||||||
api_user(), ACTIVITY_POST, $since_id, $user_info['pid'], api_user()];
|
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $user_info['pid'], api_user()];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `item`.`id` <= ?";
|
$condition[0] .= " AND `item`.`id` <= ?";
|
||||||
|
@ -2145,8 +2146,8 @@ function api_statuses_user_timeline($type)
|
||||||
}
|
}
|
||||||
$start = ($page - 1) * $count;
|
$start = ($page - 1) * $count;
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ? AND `item`.`contact-id` = ?",
|
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `item`.`id` > ? AND `item`.`contact-id` = ?",
|
||||||
api_user(), ACTIVITY_POST, $since_id, $user_info['cid']];
|
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $user_info['cid']];
|
||||||
|
|
||||||
if ($user_info['self'] == 1) {
|
if ($user_info['self'] == 1) {
|
||||||
$condition[0] .= ' AND `item`.`wall` ';
|
$condition[0] .= ' AND `item`.`wall` ';
|
||||||
|
@ -2299,8 +2300,8 @@ function api_favorites($type)
|
||||||
|
|
||||||
$start = $page*$count;
|
$start = $page*$count;
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND `starred`",
|
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `starred`",
|
||||||
api_user(), ACTIVITY_POST, $since_id];
|
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||||
|
|
||||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||||
|
|
||||||
|
@ -3099,8 +3100,8 @@ function api_lists_statuses($type)
|
||||||
|
|
||||||
$start = $page * $count;
|
$start = $page * $count;
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND `group_member`.`gid` = ?",
|
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `group_member`.`gid` = ?",
|
||||||
api_user(), ACTIVITY_POST, $since_id, $_REQUEST['list_id']];
|
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $_REQUEST['list_id']];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$condition[0] .= " AND `item`.`id` <= ?";
|
$condition[0] .= " AND `item`.`id` <= ?";
|
||||||
|
@ -4630,8 +4631,8 @@ function prepare_photo_data($type, $scale, $photo_id)
|
||||||
$data['photo']['friendica_activities'] = api_format_items_activities($item, $type);
|
$data['photo']['friendica_activities'] = api_format_items_activities($item, $type);
|
||||||
|
|
||||||
// retrieve comments on photo
|
// retrieve comments on photo
|
||||||
$condition = ["`parent` = ? AND `uid` = ? AND (`verb` = ? OR `type`='photo')",
|
$condition = ["`parent` = ? AND `uid` = ? AND (`gravity` IN (?, ?) OR `type`='photo')",
|
||||||
$item[0]['parent'], api_user(), ACTIVITY_POST];
|
$item[0]['parent'], api_user(), GRAVITY_PARENT, GRAVITY_COMMENT];
|
||||||
|
|
||||||
$statuses = Item::selectForUser(api_user(), [], $condition);
|
$statuses = Item::selectForUser(api_user(), [], $condition);
|
||||||
|
|
||||||
|
|
|
@ -740,9 +740,9 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
// We need the additional check for the "local_profile" because of mixed situations on connector networks
|
// We need the additional check for the "local_profile" because of mixed situations on connector networks
|
||||||
$item = q("SELECT `id`, `mention`, `tag`,`parent`, `title`, `body`, `author-id`, `guid`,
|
$item = q("SELECT `id`, `mention`, `tag`,`parent`, `title`, `body`, `author-id`, `guid`,
|
||||||
`parent-uri`, `uri`, `contact-id`, `network`
|
`parent-uri`, `uri`, `contact-id`, `network`
|
||||||
FROM `item` WHERE `id` = %d AND `verb` IN ('%s', '') AND `type` != 'activity' AND
|
FROM `item` WHERE `id` = %d AND `gravity` IN (%d, %d) AND
|
||||||
NOT (`author-id` IN ($contact_list)) LIMIT 1",
|
NOT (`author-id` IN ($contact_list)) LIMIT 1",
|
||||||
intval($itemid), dbesc(ACTIVITY_POST));
|
intval($itemid), intval(GRAVITY_PARENT), intval(GRAVITY_COMMENT));
|
||||||
if (!$item)
|
if (!$item)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -567,7 +567,7 @@ function item_post(App $a) {
|
||||||
$network = NETWORK_DFRN;
|
$network = NETWORK_DFRN;
|
||||||
}
|
}
|
||||||
|
|
||||||
$gravity = ($parent ? 6 : 0);
|
$gravity = ($parent ? GRAVITY_COMMENT : GRAVITY_PARENT);
|
||||||
|
|
||||||
// even if the post arrived via API we are considering that it
|
// even if the post arrived via API we are considering that it
|
||||||
// originated on this site by default for determining relayability.
|
// originated on this site by default for determining relayability.
|
||||||
|
|
|
@ -756,7 +756,7 @@ function networkThreadedView(App $a, $update, $parent)
|
||||||
// Load all unseen items
|
// Load all unseen items
|
||||||
$sql_extra4 = "`item`.`unseen`";
|
$sql_extra4 = "`item`.`unseen`";
|
||||||
if (Config::get("system", "like_no_comment")) {
|
if (Config::get("system", "like_no_comment")) {
|
||||||
$sql_extra4 .= " AND `item`.`verb` = '".ACTIVITY_POST."'";
|
$sql_extra4 .= " AND `item`.`gravity` IN (" . GRAVITY_PARENT . "," . GRAVITY_COMMENT . ")";
|
||||||
}
|
}
|
||||||
if ($order === 'post') {
|
if ($order === 'post') {
|
||||||
// Only show toplevel posts when updating posts in this order mode
|
// Only show toplevel posts when updating posts in this order mode
|
||||||
|
|
|
@ -640,6 +640,7 @@ function photos_post(App $a)
|
||||||
$arr['deny_gid'] = $p[0]['deny_gid'];
|
$arr['deny_gid'] = $p[0]['deny_gid'];
|
||||||
$arr['visible'] = 1;
|
$arr['visible'] = 1;
|
||||||
$arr['verb'] = ACTIVITY_TAG;
|
$arr['verb'] = ACTIVITY_TAG;
|
||||||
|
$arr['gravity'] = GRAVITY_PARENT;
|
||||||
$arr['object-type'] = ACTIVITY_OBJ_PERSON;
|
$arr['object-type'] = ACTIVITY_OBJ_PERSON;
|
||||||
$arr['target-type'] = ACTIVITY_OBJ_IMAGE;
|
$arr['target-type'] = ACTIVITY_OBJ_IMAGE;
|
||||||
$arr['tag'] = $tagged[4];
|
$arr['tag'] = $tagged[4];
|
||||||
|
|
|
@ -243,17 +243,14 @@ function profile_content(App $a, $update = 0)
|
||||||
|
|
||||||
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`, `item`.`created`
|
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`, `item`.`created`
|
||||||
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
|
||||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
|
WHERE `item`.`uid` = %d AND `item`.`visible` AND
|
||||||
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE . "'
|
(NOT `item`.`deleted` OR `item`.`gravity` = %d)
|
||||||
OR item.verb = '" . ACTIVITY_DISLIKE . "' OR item.verb = '" . ACTIVITY_ATTEND . "'
|
AND NOT `item`.`moderated` AND `item`.`wall`
|
||||||
OR item.verb = '" . ACTIVITY_ATTENDNO . "' OR item.verb = '" . ACTIVITY_ATTENDMAYBE . "')
|
|
||||||
AND `item`.`moderated` = 0
|
|
||||||
AND `item`.`wall` = 1
|
|
||||||
$sql_extra4
|
$sql_extra4
|
||||||
$sql_extra
|
$sql_extra
|
||||||
ORDER BY `item`.`created` DESC",
|
ORDER BY `item`.`created` DESC",
|
||||||
intval($a->profile['profile_uid'])
|
intval($a->profile['profile_uid']), intval(GRAVITY_ACTIVITY)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
|
|
|
@ -125,7 +125,7 @@ EOT;
|
||||||
$arr['type'] = 'activity';
|
$arr['type'] = 'activity';
|
||||||
$arr['wall'] = $item['wall'];
|
$arr['wall'] = $item['wall'];
|
||||||
$arr['origin'] = 1;
|
$arr['origin'] = 1;
|
||||||
$arr['gravity'] = GRAVITY_LIKE;
|
$arr['gravity'] = GRAVITY_ACTIVITY;
|
||||||
$arr['parent'] = $item['id'];
|
$arr['parent'] = $item['id'];
|
||||||
$arr['parent-uri'] = $item['uri'];
|
$arr['parent-uri'] = $item['uri'];
|
||||||
$arr['thr-parent'] = $item['uri'];
|
$arr['thr-parent'] = $item['uri'];
|
||||||
|
|
|
@ -1270,6 +1270,7 @@ class DBStructure
|
||||||
"target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
|
"target-type" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams target type if applicable (URI)"],
|
||||||
"target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
|
"target" => ["type" => "text", "comment" => "JSON encoded target structure if used"],
|
||||||
"plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
|
"plink" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "permalink or URL to a displayable copy of the message at its source"],
|
||||||
|
"verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => "ActivityStreams verb"],
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["id"],
|
"PRIMARY" => ["id"],
|
||||||
|
|
|
@ -1064,8 +1064,8 @@ class Contact extends BaseObject
|
||||||
|
|
||||||
$contact = ($r[0]["contact-type"] == ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
|
$contact = ($r[0]["contact-type"] == ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
|
||||||
|
|
||||||
$condition = ["`$contact` = ? AND `verb` = ? AND " . $sql,
|
$condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql,
|
||||||
$author_id, ACTIVITY_POST, local_user()];
|
$author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
|
||||||
$params = ['order' => ['created' => true],
|
$params = ['order' => ['created' => true],
|
||||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||||
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Item extends BaseObject
|
||||||
|
|
||||||
// Field list for "item-content" table that is mixed with the item table
|
// Field list for "item-content" table that is mixed with the item table
|
||||||
const CONTENT_FIELDLIST = ['title', 'content-warning', 'body', 'location',
|
const CONTENT_FIELDLIST = ['title', 'content-warning', 'body', 'location',
|
||||||
'coord', 'app', 'rendered-hash', 'rendered-html',
|
'coord', 'app', 'rendered-hash', 'rendered-html', 'verb',
|
||||||
'object-type', 'object', 'target-type', 'target'];
|
'object-type', 'object', 'target-type', 'target'];
|
||||||
|
|
||||||
// All fields in the item table
|
// All fields in the item table
|
||||||
|
@ -86,7 +86,7 @@ class Item extends BaseObject
|
||||||
|
|
||||||
// Fetch data from the item-content table whenever there is content there
|
// Fetch data from the item-content table whenever there is content there
|
||||||
foreach (self::CONTENT_FIELDLIST as $field) {
|
foreach (self::CONTENT_FIELDLIST as $field) {
|
||||||
if (is_null($row[$field]) && !is_null($row['item-' . $field])) {
|
if (empty($row[$field]) && !empty($row['item-' . $field])) {
|
||||||
$row[$field] = $row['item-' . $field];
|
$row[$field] = $row['item-' . $field];
|
||||||
}
|
}
|
||||||
unset($row['item-' . $field]);
|
unset($row['item-' . $field]);
|
||||||
|
@ -143,6 +143,27 @@ class Item extends BaseObject
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if item data exists
|
||||||
|
*
|
||||||
|
* @param array $condition array of fields for condition
|
||||||
|
*
|
||||||
|
* @return boolean Are there rows for that condition?
|
||||||
|
*/
|
||||||
|
public static function exists($condition) {
|
||||||
|
$stmt = self::select(['id'], $condition, ['limit' => 1]);
|
||||||
|
|
||||||
|
if (is_bool($stmt)) {
|
||||||
|
$retval = $stmt;
|
||||||
|
} else {
|
||||||
|
$retval = (dba::num_rows($stmt) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
dba::close($stmt);
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a single record from the item table for a given user and returns it in an associative array
|
* Retrieve a single record from the item table for a given user and returns it in an associative array
|
||||||
*
|
*
|
||||||
|
@ -377,12 +398,12 @@ class Item extends BaseObject
|
||||||
|
|
||||||
$fields['item'] = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
|
$fields['item'] = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
|
||||||
'contact-id', 'owner-id', 'author-id', 'type', 'wall', 'gravity', 'extid',
|
'contact-id', 'owner-id', 'author-id', 'type', 'wall', 'gravity', 'extid',
|
||||||
'created', 'edited', 'commented', 'received', 'changed', 'verb',
|
'created', 'edited', 'commented', 'received', 'changed', 'postopts',
|
||||||
'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform',
|
'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform',
|
||||||
'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
||||||
'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
|
'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
|
||||||
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global',
|
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global',
|
||||||
'id' => 'item_id', 'network'];
|
'id' => 'item_id', 'network', 'icid'];
|
||||||
|
|
||||||
$fields['item-content'] = self::CONTENT_FIELDLIST;
|
$fields['item-content'] = self::CONTENT_FIELDLIST;
|
||||||
|
|
||||||
|
@ -728,15 +749,14 @@ class Item extends BaseObject
|
||||||
self::deleteTagsFromItem($item);
|
self::deleteTagsFromItem($item);
|
||||||
|
|
||||||
// Set the item to "deleted"
|
// Set the item to "deleted"
|
||||||
dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
|
dba::update('item', ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
|
||||||
'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
|
|
||||||
['id' => $item['id']]);
|
['id' => $item['id']]);
|
||||||
|
|
||||||
Term::insertFromTagFieldByItemId($item['id']);
|
Term::insertFromTagFieldByItemId($item['id']);
|
||||||
Term::insertFromFileFieldByItemId($item['id']);
|
Term::insertFromFileFieldByItemId($item['id']);
|
||||||
self::deleteThread($item['id'], $item['parent-uri']);
|
self::deleteThread($item['id'], $item['parent-uri']);
|
||||||
|
|
||||||
if (!dba::exists('item', ["`uri` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri']])) {
|
if (!self::exists(["`uri` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri']])) {
|
||||||
self::delete(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $priority);
|
self::delete(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,18 +973,21 @@ class Item extends BaseObject
|
||||||
$item['parent-uri'] = $item['thr-parent'];
|
$item['parent-uri'] = $item['thr-parent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x($item, 'gravity')) {
|
$item['type'] = defaults($item, 'type', 'remote');
|
||||||
|
|
||||||
|
if (isset($item['gravity'])) {
|
||||||
$item['gravity'] = intval($item['gravity']);
|
$item['gravity'] = intval($item['gravity']);
|
||||||
} elseif ($item['parent-uri'] === $item['uri']) {
|
} elseif ($item['parent-uri'] === $item['uri']) {
|
||||||
$item['gravity'] = 0;
|
$item['gravity'] = GRAVITY_PARENT;
|
||||||
} elseif (activity_match($item['verb'],ACTIVITY_POST)) {
|
} elseif (activity_match($item['verb'], ACTIVITY_POST)) {
|
||||||
$item['gravity'] = 6;
|
$item['gravity'] = GRAVITY_COMMENT;
|
||||||
|
} elseif ($item['type'] == 'activity') {
|
||||||
|
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||||
} else {
|
} else {
|
||||||
$item['gravity'] = 6; // extensible catchall
|
$item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
|
||||||
|
logger('Unknown gravity for verb: ' . $item['verb'] . ' - type: ' . $item['type'], LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['type'] = defaults($item, 'type', 'remote');
|
|
||||||
|
|
||||||
$uid = intval($item['uid']);
|
$uid = intval($item['uid']);
|
||||||
|
|
||||||
// check for create date and expire time
|
// check for create date and expire time
|
||||||
|
@ -1117,7 +1140,7 @@ class Item extends BaseObject
|
||||||
// Checking if there is already an item with the same guid
|
// Checking if there is already an item with the same guid
|
||||||
logger('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], LOGGER_DEBUG);
|
logger('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], LOGGER_DEBUG);
|
||||||
$condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
|
$condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
|
||||||
if (dba::exists('item', $condition)) {
|
if (self::exists($condition)) {
|
||||||
logger('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], LOGGER_DEBUG);
|
logger('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], LOGGER_DEBUG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1219,7 +1242,7 @@ class Item extends BaseObject
|
||||||
logger('$force_parent=true, reply converted to top-level post.');
|
logger('$force_parent=true, reply converted to top-level post.');
|
||||||
$parent_id = 0;
|
$parent_id = 0;
|
||||||
$item['parent-uri'] = $item['uri'];
|
$item['parent-uri'] = $item['uri'];
|
||||||
$item['gravity'] = 0;
|
$item['gravity'] = GRAVITY_PARENT;
|
||||||
} else {
|
} else {
|
||||||
logger('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item');
|
logger('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item');
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1231,7 +1254,7 @@ class Item extends BaseObject
|
||||||
|
|
||||||
$condition = ["`uri` = ? AND `network` IN (?, ?) AND `uid` = ?",
|
$condition = ["`uri` = ? AND `network` IN (?, ?) AND `uid` = ?",
|
||||||
$item['uri'], $item['network'], NETWORK_DFRN, $item['uid']];
|
$item['uri'], $item['network'], NETWORK_DFRN, $item['uid']];
|
||||||
if (dba::exists('item', $condition)) {
|
if (self::exists($condition)) {
|
||||||
logger('duplicated item with the same uri found. '.print_r($item,true));
|
logger('duplicated item with the same uri found. '.print_r($item,true));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1262,7 @@ class Item extends BaseObject
|
||||||
// On Friendica and Diaspora the GUID is unique
|
// On Friendica and Diaspora the GUID is unique
|
||||||
if (in_array($item['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
if (in_array($item['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
||||||
$condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
|
$condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
|
||||||
if (dba::exists('item', $condition)) {
|
if (self::exists($condition)) {
|
||||||
logger('duplicated item with the same guid found. '.print_r($item,true));
|
logger('duplicated item with the same guid found. '.print_r($item,true));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1247,7 +1270,7 @@ class Item extends BaseObject
|
||||||
// Check for an existing post with the same content. There seems to be a problem with OStatus.
|
// Check for an existing post with the same content. There seems to be a problem with OStatus.
|
||||||
$condition = ["`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?",
|
$condition = ["`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?",
|
||||||
$item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']];
|
$item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']];
|
||||||
if (dba::exists('item', $condition)) {
|
if (self::exists($condition)) {
|
||||||
logger('duplicated item with the same body found. '.print_r($item,true));
|
logger('duplicated item with the same body found. '.print_r($item,true));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1260,7 +1283,7 @@ class Item extends BaseObject
|
||||||
// Set the global flag on all items if this was a global item entry
|
// Set the global flag on all items if this was a global item entry
|
||||||
dba::update('item', ['global' => true], ['uri' => $item["uri"]]);
|
dba::update('item', ['global' => true], ['uri' => $item["uri"]]);
|
||||||
} else {
|
} else {
|
||||||
$item["global"] = dba::exists('item', ['uid' => 0, 'uri' => $item["uri"]]);
|
$item["global"] = self::exists(['uid' => 0, 'uri' => $item["uri"]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACL settings
|
// ACL settings
|
||||||
|
@ -1301,7 +1324,7 @@ class Item extends BaseObject
|
||||||
* An unique index would help - but the limitations of MySQL (maximum size of index values) prevent this.
|
* An unique index would help - but the limitations of MySQL (maximum size of index values) prevent this.
|
||||||
*/
|
*/
|
||||||
if ($item["uid"] == 0) {
|
if ($item["uid"] == 0) {
|
||||||
if (dba::exists('item', ['uri' => trim($item['uri']), 'uid' => 0])) {
|
if (self::exists(['uri' => trim($item['uri']), 'uid' => 0])) {
|
||||||
logger('Global item already stored. URI: '.$item['uri'].' on network '.$item['network'], LOGGER_DEBUG);
|
logger('Global item already stored. URI: '.$item['uri'].' on network '.$item['network'], LOGGER_DEBUG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1668,7 +1691,7 @@ class Item extends BaseObject
|
||||||
if (DBM::is_result($item) && ($item["allow_cid"] == '') && ($item["allow_gid"] == '') &&
|
if (DBM::is_result($item) && ($item["allow_cid"] == '') && ($item["allow_gid"] == '') &&
|
||||||
($item["deny_cid"] == '') && ($item["deny_gid"] == '')) {
|
($item["deny_cid"] == '') && ($item["deny_gid"] == '')) {
|
||||||
|
|
||||||
if (!dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) {
|
if (!self::exists(['uri' => $item['uri'], 'uid' => 0])) {
|
||||||
// Preparing public shadow (removing user specific data)
|
// Preparing public shadow (removing user specific data)
|
||||||
$item['uid'] = 0;
|
$item['uid'] = 0;
|
||||||
unset($item['id']);
|
unset($item['id']);
|
||||||
|
@ -1722,12 +1745,12 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there a shadow parent?
|
// Is there a shadow parent?
|
||||||
if (!dba::exists('item', ['uri' => $item['parent-uri'], 'uid' => 0])) {
|
if (!self::exists(['uri' => $item['parent-uri'], 'uid' => 0])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there already a shadow entry?
|
// Is there already a shadow entry?
|
||||||
if (dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) {
|
if (self::exists(['uri' => $item['uri'], 'uid' => 0])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1757,7 +1780,7 @@ class Item extends BaseObject
|
||||||
|
|
||||||
// If this was a comment to a Diaspora post we don't get our comment back.
|
// If this was a comment to a Diaspora post we don't get our comment back.
|
||||||
// This means that we have to distribute the comment by ourselves.
|
// This means that we have to distribute the comment by ourselves.
|
||||||
if ($origin && dba::exists('item', ['id' => $parent, 'network' => NETWORK_DIASPORA])) {
|
if ($origin && self::exists(['id' => $parent, 'network' => NETWORK_DIASPORA])) {
|
||||||
self::distribute($public_shadow);
|
self::distribute($public_shadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2567,30 +2590,32 @@ class Item extends BaseObject
|
||||||
// event participation are essentially radio toggles. If you make a subsequent choice,
|
// event participation are essentially radio toggles. If you make a subsequent choice,
|
||||||
// we need to eradicate your first choice.
|
// we need to eradicate your first choice.
|
||||||
if ($event_verb_flag) {
|
if ($event_verb_flag) {
|
||||||
$verbs = "'" . dbesc(ACTIVITY_ATTEND) . "', '" . dbesc(ACTIVITY_ATTENDNO) . "', '" . dbesc(ACTIVITY_ATTENDMAYBE) . "'";
|
$verbs = [ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE];
|
||||||
} else {
|
} else {
|
||||||
$verbs = "'".dbesc($activity)."'";
|
$verbs = $activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @todo This query is expected to be a performance eater due to the "OR" - it has to be changed totally
|
$base_condition = ['verb' => $verbs, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY,
|
||||||
$existing_like = q("SELECT `id`, `guid`, `verb` FROM `item`
|
'author-id' => $author_contact['id'], 'uid' => item['uid']];
|
||||||
WHERE `verb` IN ($verbs)
|
|
||||||
AND `deleted` = 0
|
$condition = array_merge($base_condition, ['parent' => $item_id]);
|
||||||
AND `author-id` = %d
|
$like_item = self::selectFirst(['id', 'guid', 'verb'], $condition);
|
||||||
AND `uid` = %d
|
|
||||||
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s')
|
if (!DBM::is_result($like_item)) {
|
||||||
LIMIT 1",
|
$condition = array_merge($base_condition, ['parent-uri' => $item_id]);
|
||||||
intval($author_contact['id']),
|
$like_item = self::selectFirst(['id', 'guid', 'verb'], $condition);
|
||||||
intval($item['uid']),
|
}
|
||||||
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
|
|
||||||
);
|
if (!DBM::is_result($like_item)) {
|
||||||
|
$condition = array_merge($base_condition, ['thr-parent' => $item_id]);
|
||||||
|
$like_item = self::selectFirst(['id', 'guid', 'verb'], $condition);
|
||||||
|
}
|
||||||
|
|
||||||
// If it exists, mark it as deleted
|
// If it exists, mark it as deleted
|
||||||
if (DBM::is_result($existing_like)) {
|
if (DBM::is_result($like_item)) {
|
||||||
$like_item = $existing_like[0];
|
|
||||||
|
|
||||||
// Already voted, undo it
|
// Already voted, undo it
|
||||||
$fields = ['deleted' => true, 'unseen' => true, 'changed' => DateTimeFormat::utcNow()];
|
$fields = ['deleted' => true, 'unseen' => true, 'changed' => DateTimeFormat::utcNow()];
|
||||||
|
/// @todo Consider using self::update - but before doing so, check the side effects
|
||||||
dba::update('item', $fields, ['id' => $like_item['id']]);
|
dba::update('item', $fields, ['id' => $like_item['id']]);
|
||||||
|
|
||||||
// Clean up the Diaspora signatures for this like
|
// Clean up the Diaspora signatures for this like
|
||||||
|
@ -2644,7 +2669,7 @@ EOT;
|
||||||
'type' => 'activity',
|
'type' => 'activity',
|
||||||
'wall' => $item['wall'],
|
'wall' => $item['wall'],
|
||||||
'origin' => 1,
|
'origin' => 1,
|
||||||
'gravity' => GRAVITY_LIKE,
|
'gravity' => GRAVITY_ACTIVITY,
|
||||||
'parent' => $item['id'],
|
'parent' => $item['id'],
|
||||||
'parent-uri' => $item['uri'],
|
'parent-uri' => $item['uri'],
|
||||||
'thr-parent' => $item['uri'],
|
'thr-parent' => $item['uri'],
|
||||||
|
@ -2754,7 +2779,7 @@ EOT;
|
||||||
|
|
||||||
if ($itemuri != "") {
|
if ($itemuri != "") {
|
||||||
$condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]];
|
$condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]];
|
||||||
if (!dba::exists('item', $condition)) {
|
if (!self::exists($condition)) {
|
||||||
dba::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
dba::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
||||||
logger("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
|
logger("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Term
|
||||||
$profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
|
$profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
|
||||||
|
|
||||||
$fields = ['guid', 'uid', 'id', 'edited', 'deleted', 'created', 'received', 'title', 'body', 'tag', 'parent'];
|
$fields = ['guid', 'uid', 'id', 'edited', 'deleted', 'created', 'received', 'title', 'body', 'tag', 'parent'];
|
||||||
$message = dba::selectFirst('item', $fields, ['id' => $itemid]);
|
$message = Item::selectFirst($fields, ['id' => $itemid]);
|
||||||
if (!DBM::is_result($message)) {
|
if (!DBM::is_result($message)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class Term
|
||||||
*/
|
*/
|
||||||
public static function insertFromFileFieldByItemId($itemid)
|
public static function insertFromFileFieldByItemId($itemid)
|
||||||
{
|
{
|
||||||
$message = dba::selectFirst('item', ['uid', 'deleted', 'file'], ['id' => $itemid]);
|
$message = Item::selectFirst(['uid', 'deleted', 'file'], ['id' => $itemid]);
|
||||||
if (!DBM::is_result($message)) {
|
if (!DBM::is_result($message)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2310,18 +2310,18 @@ class DFRN
|
||||||
) {
|
) {
|
||||||
$is_like = true;
|
$is_like = true;
|
||||||
$item["type"] = "activity";
|
$item["type"] = "activity";
|
||||||
$item["gravity"] = GRAVITY_LIKE;
|
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||||
// only one like or dislike per person
|
// only one like or dislike per person
|
||||||
// splitted into two queries for performance issues
|
// splitted into two queries for performance issues
|
||||||
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"],
|
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
|
||||||
'verb' => $item["verb"], 'parent-uri' => $item["parent-uri"]];
|
'verb' => $item["verb"], 'parent-uri' => $item["parent-uri"]];
|
||||||
if (dba::exists('item', $condition)) {
|
if (Item::exists($condition)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"],
|
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
|
||||||
'verb' => $item["verb"], 'thr-parent' => $item["parent-uri"]];
|
'verb' => $item["verb"], 'thr-parent' => $item["parent-uri"]];
|
||||||
if (dba::exists('item', $condition)) {
|
if (Item::exists($condition)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2770,7 +2770,7 @@ class DFRN
|
||||||
// Comments can be deleted by the thread owner or comment owner
|
// Comments can be deleted by the thread owner or comment owner
|
||||||
if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) {
|
if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) {
|
||||||
$condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]];
|
$condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]];
|
||||||
if (!dba::exists('item', $condition)) {
|
if (!Item::exists($condition)) {
|
||||||
logger("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);
|
logger("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2049,7 +2049,7 @@ class Diaspora
|
||||||
|
|
||||||
$datarray["type"] = "activity";
|
$datarray["type"] = "activity";
|
||||||
$datarray["verb"] = $verb;
|
$datarray["verb"] = $verb;
|
||||||
$datarray["gravity"] = GRAVITY_LIKE;
|
$datarray["gravity"] = GRAVITY_ACTIVITY;
|
||||||
$datarray["parent-uri"] = $parent_item["uri"];
|
$datarray["parent-uri"] = $parent_item["uri"];
|
||||||
|
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||||
|
|
|
@ -416,7 +416,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deletions come with the same uri, so we check for duplicates after processing deletions
|
// Deletions come with the same uri, so we check for duplicates after processing deletions
|
||||||
if (dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
|
if (Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
|
||||||
logger('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
|
logger('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -451,7 +451,7 @@ class OStatus
|
||||||
|
|
||||||
$item["verb"] = ACTIVITY_LIKE;
|
$item["verb"] = ACTIVITY_LIKE;
|
||||||
$item["parent-uri"] = $orig_uri;
|
$item["parent-uri"] = $orig_uri;
|
||||||
$item["gravity"] = GRAVITY_LIKE;
|
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
||||||
|
@ -489,7 +489,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// But we will only import complete threads
|
// But we will only import complete threads
|
||||||
$valid = dba::exists('item', ['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
|
$valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
logger("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG);
|
logger("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (self::$itemlist as $item) {
|
foreach (self::$itemlist as $item) {
|
||||||
$found = dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item["uri"]]);
|
$found = Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]);
|
||||||
if ($found) {
|
if ($found) {
|
||||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
|
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
|
||||||
} elseif ($item['contact-id'] < 0) {
|
} elseif ($item['contact-id'] < 0) {
|
||||||
|
@ -537,8 +537,8 @@ class OStatus
|
||||||
*/
|
*/
|
||||||
private static function deleteNotice($item)
|
private static function deleteNotice($item)
|
||||||
{
|
{
|
||||||
$condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
|
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'uri' => $item['uri']];
|
||||||
if (!dba::exists('item', $condition)) {
|
if (!Item::exists($condition)) {
|
||||||
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it.");
|
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -674,7 +674,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item["parent-uri"])) {
|
if (isset($item["parent-uri"])) {
|
||||||
if (!dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
|
if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
|
||||||
if ($related != '') {
|
if ($related != '') {
|
||||||
self::fetchRelated($related, $item["parent-uri"], $importer);
|
self::fetchRelated($related, $item["parent-uri"], $importer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,7 +389,7 @@ class OnePoll
|
||||||
// Have we seen it before?
|
// Have we seen it before?
|
||||||
$fields = ['deleted', 'id'];
|
$fields = ['deleted', 'id'];
|
||||||
$condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
|
$condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
|
||||||
$item = dba::selectFirst('item', $fields, $condition);
|
$item = Item::selectFirst($fields, $condition);
|
||||||
if (DBM::is_result($item)) {
|
if (DBM::is_result($item)) {
|
||||||
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
|
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ class OnePoll
|
||||||
$refs_arr = explode(' ', $raw_refs);
|
$refs_arr = explode(' ', $raw_refs);
|
||||||
if (count($refs_arr)) {
|
if (count($refs_arr)) {
|
||||||
for ($x = 0; $x < count($refs_arr); $x ++) {
|
for ($x = 0; $x < count($refs_arr); $x ++) {
|
||||||
$refs_arr[$x] = "'" . Email::msgid2iri(str_replace(['<', '>', ' '],['', '', ''],dbesc($refs_arr[$x]))) . "'";
|
$refs_arr[$x] = Email::msgid2iri(str_replace(['<', '>', ' '],['', '', ''], $refs_arr[$x]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$condition = ['uri' => $refs_arr, 'uid' => $importer_uid];
|
$condition = ['uri' => $refs_arr, 'uid' => $importer_uid];
|
||||||
|
|
Loading…
Reference in a new issue