OStatus: Attachment links are now added as enclosures
This commit is contained in:
parent
e6e7562986
commit
f34135f34d
|
@ -13,9 +13,9 @@ function bb_map_location($match) {
|
||||||
return str_replace($match[0],'<div class="map" >' . generate_named_map($match[1]) . '</div>', $match[0]);
|
return str_replace($match[0],'<div class="map" >' . generate_named_map($match[1]) . '</div>', $match[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
|
function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
|
||||||
$Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
|
$Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
|
||||||
function ($match) use ($plaintext, $tryoembed){
|
function ($match) use ($simplehtml, $tryoembed){
|
||||||
|
|
||||||
$attributes = $match[2];
|
$attributes = $match[2];
|
||||||
|
|
||||||
|
@ -83,7 +83,10 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
|
||||||
$image = "";
|
$image = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($plaintext)
|
if ($simplehtml == 7)
|
||||||
|
$text = sprintf('<a href="%s" title="%s" class="attachment thumbnail" rel="nofollow external">%s</a>',
|
||||||
|
$url, $title, $title);
|
||||||
|
elseif (($simplehtml != 4) AND ($simplehtml != 0))
|
||||||
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title);
|
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title);
|
||||||
else {
|
else {
|
||||||
$text = sprintf('<span class="type-%s">', $type);
|
$text = sprintf('<span class="type-%s">', $type);
|
||||||
|
@ -871,7 +874,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle attached links or videos
|
// Handle attached links or videos
|
||||||
$Text = bb_attachment($Text, ($simplehtml != 4) AND ($simplehtml != 0), $tryoembed);
|
$Text = bb_attachment($Text, $simplehtml, $tryoembed);
|
||||||
|
|
||||||
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
|
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ require_once('include/email.php');
|
||||||
require_once('include/ostatus_conversation.php');
|
require_once('include/ostatus_conversation.php');
|
||||||
require_once('include/threads.php');
|
require_once('include/threads.php');
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
|
require_once('include/plaintext.php');
|
||||||
require_once('mod/share.php');
|
require_once('mod/share.php');
|
||||||
|
|
||||||
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0, $forpubsub = false) {
|
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0, $forpubsub = false) {
|
||||||
|
@ -4344,7 +4345,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
||||||
if ($item['title'] != "")
|
if ($item['title'] != "")
|
||||||
$htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody;
|
$htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody;
|
||||||
|
|
||||||
$htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7);
|
//$htmlbody = bbcode(bb_remove_share_information($htmlbody), false, false, 7);
|
||||||
|
$htmlbody = bbcode($htmlbody, false, false, 7);
|
||||||
|
|
||||||
$o .= '<id>' . xmlify($item['uri']) . '</id>' . "\r\n";
|
$o .= '<id>' . xmlify($item['uri']) . '</id>' . "\r\n";
|
||||||
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
|
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
|
||||||
|
@ -4401,6 +4403,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$o .= item_get_attachment($item);
|
||||||
|
|
||||||
$o .= item_getfeedattach($item);
|
$o .= item_getfeedattach($item);
|
||||||
|
|
||||||
$mentioned = get_mentions($item);
|
$mentioned = get_mentions($item);
|
||||||
|
@ -4578,6 +4582,28 @@ function item_getfeedtags($item) {
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function item_get_attachment($item) {
|
||||||
|
$o = "";
|
||||||
|
$siteinfo = get_attached_data($item["body"]);
|
||||||
|
|
||||||
|
switch($siteinfo["type"]) {
|
||||||
|
case 'link':
|
||||||
|
$o = '<link rel="enclosure" href="'.xmlify($siteinfo["url"]).'" type="text/html; charset=UTF-8" length="" title="'.xmlify($siteinfo["title"]).'"/>'."\r\n";
|
||||||
|
break;
|
||||||
|
case 'photo':
|
||||||
|
$imgdata = get_photo_info($siteinfo["image"]);
|
||||||
|
$o = '<link rel="enclosure" href="'.xmlify($siteinfo["image"]).'" type="'.$imgdata["mime"].'" length="'.$imgdata["size"].'"/>'."\r\n";
|
||||||
|
break;
|
||||||
|
case 'video':
|
||||||
|
$o = '<link rel="enclosure" href="'.xmlify($siteinfo["url"]).'" type="text/html; charset=UTF-8" length="" title="'.xmlify($siteinfo["title"]).'"/>'."\r\n";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
function item_getfeedattach($item) {
|
function item_getfeedattach($item) {
|
||||||
$ret = '';
|
$ret = '';
|
||||||
$arr = explode('[/attach],',$item['attach']);
|
$arr = explode('[/attach],',$item['attach']);
|
||||||
|
|
|
@ -53,8 +53,9 @@ function check_conversations($override = false) {
|
||||||
logger('cron_start');
|
logger('cron_start');
|
||||||
|
|
||||||
$start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
|
$start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
|
||||||
$conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'",
|
$conversations = q("SELECT `oid`, `url` FROM `term` WHERE `type` = 7 AND `term` > '%s' GROUP BY `url` ORDER BY `term` DESC",
|
||||||
dbesc($start));
|
dbesc($start));
|
||||||
|
|
||||||
foreach ($conversations AS $conversation) {
|
foreach ($conversations AS $conversation) {
|
||||||
$id = $conversation['oid'];
|
$id = $conversation['oid'];
|
||||||
$url = $conversation['url'];
|
$url = $conversation['url'];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user