appnet, fbsync, statusnet and twitter: Now a parent is provided in the notifications so threading of the mails will work.
This commit is contained in:
parent
eb707da562
commit
23490bda0a
4 changed files with 83 additions and 30 deletions
|
@ -750,13 +750,30 @@ function appnet_fetchstream($a, $uid) {
|
|||
foreach ($mentions AS $post) {
|
||||
$postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, false);
|
||||
|
||||
if (isset($postarray["id"]))
|
||||
if (isset($postarray["id"])) {
|
||||
$item = $postarray["id"];
|
||||
elseif (isset($postarray["body"])) {
|
||||
$parent_id = $postarray['parent'];
|
||||
} elseif (isset($postarray["body"])) {
|
||||
$item = item_store($postarray);
|
||||
$parent_id = 0;
|
||||
logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
|
||||
} else
|
||||
} else {
|
||||
$item = 0;
|
||||
$parent_id = 0;
|
||||
}
|
||||
|
||||
// Fetch the parent and id
|
||||
if (($parent_id == 0) AND ($postarray['uri'] != "")) {
|
||||
$r = q("SELECT `id`, `parent` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r)) {
|
||||
$item = $r[0]['id'];
|
||||
$parent_id = $r[0]['parent'];
|
||||
}
|
||||
}
|
||||
|
||||
$lastid = $post["id"];
|
||||
|
||||
|
@ -776,7 +793,8 @@ function appnet_fetchstream($a, $uid) {
|
|||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item'
|
||||
'otype' => 'item',
|
||||
'parent' => $parent_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -792,7 +810,7 @@ function appnet_fetchstream($a, $uid) {
|
|||
*/
|
||||
}
|
||||
|
||||
function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true) {
|
||||
function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true, $nodupcheck = false) {
|
||||
require_once('include/items.php');
|
||||
|
||||
if ($post["machine_only"])
|
||||
|
@ -807,25 +825,33 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
|
|||
$postarray['wall'] = 0;
|
||||
$postarray['verb'] = ACTIVITY_POST;
|
||||
$postarray['network'] = dbesc(NETWORK_APPNET);
|
||||
$postarray['uri'] = "adn::".$post["id"];
|
||||
if (is_array($post["repost_of"])) {
|
||||
// You can't reply to reposts. So use the original id and thread-id
|
||||
$postarray['uri'] = "adn::".$post["repost_of"]["id"];
|
||||
$postarray['parent-uri'] = "adn::".$post["repost_of"]["thread_id"];
|
||||
} else {
|
||||
$postarray['uri'] = "adn::".$post["id"];
|
||||
$postarray['parent-uri'] = "adn::".$post["thread_id"];
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
if (!$nodupcheck) {
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
return($r[0]);
|
||||
if (count($r))
|
||||
return($r[0]);
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
return($r[0]);
|
||||
if (count($r))
|
||||
return($r[0]);
|
||||
}
|
||||
|
||||
$postarray['parent-uri'] = "adn::".$post["thread_id"];
|
||||
if (isset($post["reply_to"]) AND ($post["reply_to"] != "")) {
|
||||
$postarray['thr-parent'] = "adn::".$post["reply_to"];
|
||||
|
||||
|
@ -875,8 +901,6 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
|
|||
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
}
|
||||
|
||||
$postarray['plink'] = $post["canonical_url"];
|
||||
|
||||
if (($post["user"]["id"] != $ownid) OR ($postarray['thr-parent'] == $postarray['uri'])) {
|
||||
$postarray['owner-name'] = $post["user"]["name"];
|
||||
$postarray['owner-link'] = $post["user"]["canonical_url"];
|
||||
|
@ -905,6 +929,8 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
|
|||
$content = $post;
|
||||
}
|
||||
|
||||
$postarray['plink'] = $content["canonical_url"];
|
||||
|
||||
if (is_array($content["entities"])) {
|
||||
$converted = appnet_expand_entities($a, $content["text"], $content["entities"]);
|
||||
$postarray['body'] = $converted["body"];
|
||||
|
@ -969,11 +995,13 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
|
|||
$link = array_pop($links);
|
||||
$url = str_replace(array('/', '.'), array('\/', '\.'), $link);
|
||||
|
||||
$removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']);
|
||||
if (($removedlink == "") OR strstr($postarray['body'], $removedlink))
|
||||
$postarray['body'] = $removedlink;
|
||||
|
||||
$page_info = add_page_info($link, false, $photo["url"]);
|
||||
|
||||
if (trim($page_info) != "") {
|
||||
$removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']);
|
||||
if (($removedlink == "") OR strstr($postarray['body'], $removedlink))
|
||||
$postarray['body'] = $removedlink;
|
||||
}
|
||||
}
|
||||
|
||||
$postarray['body'] .= $page_info;
|
||||
|
|
|
@ -345,6 +345,13 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
$type = "link";
|
||||
|
||||
$content = "[bookmark=".$post->attachment->href."]".$post->attachment->name."[/bookmark]";
|
||||
|
||||
// If a link is not only attached but also added in the body, look if it can be removed in the body.
|
||||
$removedlink = trim(str_replace($post->attachment->href, "", $postarray["body"]));
|
||||
|
||||
if (($removedlink == "") OR strstr($postarray["body"], $removedlink))
|
||||
$postarray["body"] = $removedlink;
|
||||
|
||||
} elseif (isset($post->attachment->name) AND ($post->attachment->name != ""))
|
||||
$content = "[b]" . $post->attachment->name."[/b]";
|
||||
|
||||
|
|
|
@ -1078,6 +1078,7 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
|
|||
if (count($r)) {
|
||||
$postarray['thr-parent'] = $r[0]["uri"];
|
||||
$postarray['parent-uri'] = $r[0]["parent-uri"];
|
||||
$postarray['parent'] = $r[0]["parent"];
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
|
||||
} else {
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
|
@ -1087,6 +1088,7 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
|
|||
if (count($r)) {
|
||||
$postarray['thr-parent'] = $r[0]['uri'];
|
||||
$postarray['parent-uri'] = $r[0]['parent-uri'];
|
||||
$postarray['parent'] = $r[0]['parent'];
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
|
||||
} else {
|
||||
$postarray['thr-parent'] = $postarray['uri'];
|
||||
|
@ -1189,6 +1191,8 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
|
|||
|
||||
function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray) {
|
||||
|
||||
// This function necer worked and need cleanup
|
||||
|
||||
$user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
@ -1405,8 +1409,10 @@ function statusnet_fetchhometimeline($a, $uid) {
|
|||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
if (count($r))
|
||||
if (count($r)) {
|
||||
$item = $r[0]['id'];
|
||||
$parent_id = $r[0]['parent'];
|
||||
}
|
||||
|
||||
if ($item != 0) {
|
||||
require_once('include/enotify.php');
|
||||
|
@ -1423,7 +1429,8 @@ function statusnet_fetchhometimeline($a, $uid) {
|
|||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item'
|
||||
'otype' => 'item',
|
||||
'parent' => $parent_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1243,6 +1243,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
|||
if (count($r)) {
|
||||
$postarray['thr-parent'] = $r[0]["uri"];
|
||||
$postarray['parent-uri'] = $r[0]["parent-uri"];
|
||||
$postarray['parent'] = $r[0]["parent"];
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
|
||||
} else {
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
|
@ -1252,6 +1253,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
|||
if (count($r)) {
|
||||
$postarray['thr-parent'] = $r[0]['uri'];
|
||||
$postarray['parent-uri'] = $r[0]['parent-uri'];
|
||||
$postarray['parent'] = $r[0]['parent'];
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
|
||||
} else {
|
||||
$postarray['thr-parent'] = $postarray['uri'];
|
||||
|
@ -1404,6 +1406,8 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
|||
|
||||
function twitter_checknotification($a, $uid, $own_id, $top_item, $postarray) {
|
||||
|
||||
// this whole function doesn't seem to work. Needs complete check
|
||||
|
||||
$user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
@ -1592,6 +1596,9 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
|
||||
$item = item_store($postarray);
|
||||
|
||||
if (!isset($postarray["parent"]) OR ($postarray["parent"] == 0))
|
||||
$postarray["parent"] = $item;
|
||||
|
||||
logger('twitter_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
|
||||
|
||||
if ($item == 0) {
|
||||
|
@ -1599,9 +1606,12 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
if (count($r))
|
||||
if (count($r)) {
|
||||
$item = $r[0]['id'];
|
||||
}
|
||||
$parent_id = $r[0]['parent'];
|
||||
}
|
||||
} else
|
||||
$parent_id = $postarray['parent'];
|
||||
|
||||
if ($item != 0) {
|
||||
require_once('include/enotify.php');
|
||||
|
@ -1618,7 +1628,8 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item'
|
||||
'otype' => 'item',
|
||||
'parent' => $parent_id
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue