require_once("include/bbcode.php");
require_once("include/html2plain.php");
+ $b['body'] = bb_CleanPictureLinks($b['body']);
+
// Looking for the first image
$image = '';
if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$b['body'],$matches))
logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA);
+ // To-Do: if it is a reply, then only do a simple bbcode2plain conversion
$msgarr = fbpost_createmsg($b);
$msg = $msgarr["msg"];
$link = $msgarr["link"];
intval($b['id']),
intval($b['id'])
);
- }
- else {
- if(! $likes) {
+ } else {
+ // Sometimes posts are accepted from facebook although it telling an error
+ // This leads to endless comment flooding.
+
+ // If it is a special kind of failure the post was receiced
+ // Although facebook said it wasn't received ...
+ if (!$likes AND (($retj->error->type != "OAuthException") OR ($retj->error->code != 2)) AND ($x <> "")) {
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
if (count($r))
$a->contact = $r[0]["id"];
);
logger('fbpost_queue_hook: success: ' . $j);
remove_queue_item($x['id']);
- }
- else {
+ } else {
logger('fbpost_queue_hook: failed: ' . $j);
- update_queue_time($x['id']);
+
+ // If it is a special kind of failure the post was receiced
+ // Although facebook said it wasn't received ...
+ $ret = json_decode($j);
+ if (($ret->error->type != "OAuthException") OR ($ret->error->code != 2) AND ($j <> ""))
+ update_queue_time($x['id']);
+ else
+ logger('fbpost_queue_hook: Not requeued, since it seems to be received');
}
} else {
logger('fbpost_queue_hook: No fb_post or fb_token.');
$_REQUEST["body"] .= "[class=type-".$type."]";
if ($content)
- $_REQUEST["body"] .= $content;
+ $_REQUEST["body"] .= trim($content);
if ($quote)
$_REQUEST["body"] .= "\n[quote]".$quote."[/quote]";