Some code beautification.
This commit is contained in:
parent
a3c497190d
commit
af79cd316c
1 changed files with 43 additions and 43 deletions
|
@ -120,19 +120,25 @@ function ostatus_import($xml,$importer,&$contact) {
|
||||||
|
|
||||||
// Now get the item
|
// Now get the item
|
||||||
$item["uri"] = $xpath->query('atom:id/text()', $entry)->item(0)->nodeValue;
|
$item["uri"] = $xpath->query('atom:id/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
|
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
|
||||||
|
intval($importer["uid"]), dbesc($item["uri"]));
|
||||||
|
if ($r) {
|
||||||
|
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$item["body"] = html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
|
$item["body"] = html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
|
||||||
$item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
|
$item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
|
||||||
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
|
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
if ($item["verb"] == ACTIVITY_FOLLOW) {
|
if ($item["verb"] == ACTIVITY_FOLLOW) {
|
||||||
// ignore "Follow" messages
|
// ignore "Follow" messages
|
||||||
$item = array();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item["verb"] == ACTIVITY_FAVORITE) {
|
if ($item["verb"] == ACTIVITY_FAVORITE) {
|
||||||
// ignore "Favorite" messages
|
// ignore "Favorite" messages
|
||||||
$item = array();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,25 +310,23 @@ function ostatus_import($xml,$importer,&$contact) {
|
||||||
} else
|
} else
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
|
|
||||||
intval($importer["uid"]), dbesc($item["uri"]));
|
|
||||||
if (!$r) {
|
|
||||||
$item_id = item_store($item);
|
$item_id = item_store($item);
|
||||||
//echo $xml;
|
//echo $xml;
|
||||||
//print_r($item);
|
//print_r($item);
|
||||||
//echo $item_id." ".$item["parent-uri"]."\n";
|
//echo $item_id." ".$item["parent-uri"]."\n";
|
||||||
|
|
||||||
if ($item_id)
|
if (!$item_id) {
|
||||||
logger("Item was stored with id ".$item_id, LOGGER_DEBUG);
|
|
||||||
else
|
|
||||||
logger("Error storing item ".print_r($item, true), LOGGER_DEBUG);
|
logger("Error storing item ".print_r($item, true), LOGGER_DEBUG);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger("Item was stored with id ".$item_id, LOGGER_DEBUG);
|
||||||
$item["id"] = $item_id;
|
$item["id"] = $item_id;
|
||||||
|
|
||||||
if (!isset($item["parent"]) OR ($item["parent"] == 0))
|
if (!isset($item["parent"]) OR ($item["parent"] == 0))
|
||||||
$item["parent"] = $item_id;
|
$item["parent"] = $item_id;
|
||||||
|
|
||||||
if ($mention AND ($item["id"] != 0)) {
|
if ($mention) {
|
||||||
$u = q("SELECT `notify-flags`, `language`, `username`, `email` FROM user WHERE uid = %d LIMIT 1", intval($item['uid']));
|
$u = q("SELECT `notify-flags`, `language`, `username`, `email` FROM user WHERE uid = %d LIMIT 1", intval($item['uid']));
|
||||||
|
|
||||||
notification(array(
|
notification(array(
|
||||||
|
@ -342,12 +346,8 @@ function ostatus_import($xml,$importer,&$contact) {
|
||||||
'parent' => $item["parent"]
|
'parent' => $item["parent"]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$item_id = $r[0]["id"];
|
|
||||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($conversation != "") AND ($item_id != 0)) {
|
if ($conversation != "") {
|
||||||
// Check for duplicates. We really don't need to check the same conversation twice.
|
// Check for duplicates. We really don't need to check the same conversation twice.
|
||||||
if (!in_array($conversation, $conversationlist)) {
|
if (!in_array($conversation, $conversationlist)) {
|
||||||
complete_conversation($item_id, $conversation);
|
complete_conversation($item_id, $conversation);
|
||||||
|
|
Loading…
Reference in a new issue