use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
-use Friendica\Model\ItemContent;
use Friendica\Model\Photo;
+use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
function statusnet_install()
Logger::log("installed GNU Social");
}
-function statusnet_uninstall()
-{
- Hook::unregister('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
- Hook::unregister('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
- Hook::unregister('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
- Hook::unregister('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork');
- Hook::unregister('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
- Hook::unregister('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
- Hook::unregister('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
- Hook::unregister('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
- Hook::unregister('check_item_notification', 'addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
-
- // old setting - remove only
- Hook::unregister('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
- Hook::unregister('addon_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
- Hook::unregister('addon_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
-}
-
function statusnet_check_item_notification(App $a, &$notification_data)
{
if (DI::pConfig()->get($notification_data["uid"], 'statusnet', 'post')) {
foreach ($globalsn as $asn) {
if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
$apibase = $asn['apiurl'];
- $c = Network::fetchUrl($apibase . 'statusnet/version.xml');
+ $c = DI::httpRequest()->fetch($apibase . 'statusnet/version.xml');
if (strlen($c) > 0) {
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']);
DI::pConfig()->set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']);
// we'll check the API Version for that, if we don't get one we'll try to fix the path but will
// resign quickly after this one try to fix the path ;-)
$apibase = $_POST['statusnet-baseapi'];
- $c = Network::fetchUrl($apibase . 'statusnet/version.xml');
+ $c = DI::httpRequest()->fetch($apibase . 'statusnet/version.xml');
if (strlen($c) > 0) {
// ok the API path is correct, let's save the settings
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
} else {
// the API path is not correct, maybe missing trailing / ?
$apibase = $apibase . '/';
- $c = Network::fetchUrl($apibase . 'statusnet/version.xml');
+ $c = DI::httpRequest()->fetch($apibase . 'statusnet/version.xml');
if (strlen($c) > 0) {
// ok the API path is now correct, let's save the settings
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
if (!intval($_POST['statusnet-mirror']))
DI::pConfig()->delete(local_user(), 'statusnet', 'lastid');
-
- info(DI::l10n()->t('GNU Social settings updated.') . EOL);
}
}
}
if (DI::pConfig()->get($post['uid'], 'statusnet', 'import')) {
// Don't fork if it isn't a reply to a GNU Social post
- if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::STATUSNET])) {
+ if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::STATUSNET])) {
Logger::log('No GNU Social parent found for item ' . $post['id']);
$b['execute'] = false;
return;
return;
}
+ $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']);
+
$api = DI::pConfig()->get($b["uid"], 'statusnet', 'baseapi');
$hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
}
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
- $orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
+ $orig_post = Post::selectFirst(['author-link', 'uri'], $condition);
if (!DBA::isResult($orig_post)) {
Logger::log("statusnet_post_hook: no parent found " . $b["thr-parent"]);
return;
DI::pConfig()->set($b['uid'], 'statusnet', 'max_char', $max_char);
$tempfile = "";
- $msgarr = ItemContent::getPlaintextPost($b, $max_char, true, 7);
+ $msgarr = Plaintext::getPost($b, $max_char, true, 7);
$msg = $msgarr["text"];
if (($msg == "") && isset($msgarr["title"]))
}
if ($image != "") {
- $img_str = Network::fetchUrl($image);
+ $img_str = DI::httpRequest()->fetch($image);
$tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);
$postdata = ["status" => $msg, "media[]" => $tempfile];
$item["plink"] = DI::baseUrl()->get() . "/display/" . $item["guid"];
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
- $orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
+ $orig_post = Post::selectFirst(['author-link', 'uri'], $condition);
if (DBA::isResult($orig_post)) {
$nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
}
}
- $msgarr = ItemContent::getPlaintextPost($item, $max_char, true, 7);
+ $msgarr = Plaintext::getPost($item, $max_char, true, 7);
$msg = $msgarr["text"];
if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
$_REQUEST["title"] = "";
- $_REQUEST["body"] = PageInfo::searchAndAppendToBody($post->text, true);
+ $_REQUEST["body"] = $post->text;
if (is_string($post->place->name)) {
$_REQUEST["location"] = $post->place->name;
}
$postarray['uri'] = $hostname . "::" . $content->id;
- if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) {
+ if (Post::exists(['extid' => $postarray['uri'], 'uid' => $uid])) {
return [];
}
$contactid = 0;
if (!empty($content->in_reply_to_status_id)) {
+ $thr_parent = $hostname . "::" . $content->in_reply_to_status_id;
- $parent = $hostname . "::" . $content->in_reply_to_status_id;
-
- $fields = ['uri', 'parent-uri', 'parent'];
- $item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
-
+ $item = Post::selectFirst(['uri'], ['uri' => $thr_parent, 'uid' => $uid]);
if (!DBA::isResult($item)) {
- $item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
+ $item = Post::selectFirst(['uri'], ['extid' => $thr_parent, 'uid' => $uid]);
}
if (DBA::isResult($item)) {
$postarray['thr-parent'] = $item['uri'];
- $postarray['parent-uri'] = $item['parent-uri'];
- $postarray['parent'] = $item['parent'];
$postarray['object-type'] = Activity\ObjectType::COMMENT;
} else {
- $postarray['thr-parent'] = $postarray['uri'];
- $postarray['parent-uri'] = $postarray['uri'];
$postarray['object-type'] = Activity\ObjectType::NOTE;
}
// Don't create accounts of people who just comment something
$create_user = false;
} else {
- $postarray['parent-uri'] = $postarray['uri'];
$postarray['object-type'] = Activity\ObjectType::NOTE;
}
Logger::log("statusnet_convertmsg: expanding url " . $match[1], Logger::DEBUG);
- $expanded_url = Network::finalUrl($match[1]);
+ $expanded_url = DI::httpRequest()->finalUrl($match[1]);
Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG);
} elseif ($oembed_data->type != "link") {
$body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
} else {
- $img_str = Network::fetchUrl($expanded_url, true, 4);
+ $img_str = DI::httpRequest()->fetch($expanded_url, 4);
$tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);