/**
* @brief Adds an entry element to the XML document
*
- * @param object $doc XML document
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param bool $toplevel optional default false
+ * @param object $doc XML document
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param bool $toplevel optional default false
+ * @param bool $feed_mode Behave like a regular feed for users if true
*
* @return object Entry element
*/
- private static function entry(DOMDocument $doc, array $item, array $owner, $toplevel = false)
+ private static function entry(DOMDocument $doc, array $item, array $owner, $toplevel = false, $feed_mode = false)
{
$xml = null;
} elseif (in_array($item["verb"], [ACTIVITY_FOLLOW, NAMESPACE_OSTATUS."/unfollow"])) {
return self::followEntry($doc, $item, $owner, $toplevel);
} else {
- return self::noteEntry($doc, $item, $owner, $toplevel);
+ return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
}
}
/**
* @brief Adds a regular entry element
*
- * @param object $doc XML document
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param object $doc XML document
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param bool $feed_mode Behave like a regular feed for users if true
*
* @return object Entry element
*/
- private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
+ private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel, $feed_mode)
{
if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
- self::entryContent($doc, $entry, $item, $owner, $title);
+ self::entryContent($doc, $entry, $item, $owner, $title, '', true, $feed_mode);
self::entryFooter($doc, $entry, $item, $owner);
/// @todo Check if this title stuff is really needed (I guess not)
if (!$toplevel) {
$entry = $doc->createElement("entry");
- $title = sprintf("New note by %s", $owner["nick"]);
+ if (!empty($item['title'])) {
+ $title = BBCode::convert($item['title'], false, 7);
+ } else {
+ $title = sprintf("New note by %s", $owner["nick"]);
+ }
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
$contact = self::contactEntry($item['author-link'], $owner);
/**
* @brief Adds elements to the XML document
*
- * @param object $doc XML document
- * @param object $entry Entry element where the content is added
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param string $title Title for the post
- * @param string $verb The activity verb
- * @param bool $complete Add the "status_net" element?
+ * @param object $doc XML document
+ * @param object $entry Entry element where the content is added
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param string $title Title for the post
+ * @param string $verb The activity verb
+ * @param bool $complete Add the "status_net" element?
+ * @param bool $feed_mode Behave like a regular feed for users if true
* @return void
*/
- private static function entryContent(DOMDocument $doc, $entry, array $item, array $owner, $title, $verb = "", $complete = true)
+ private static function entryContent(DOMDocument $doc, $entry, array $item, array $owner, $title, $verb = "", $complete = true, $feed_mode = false)
{
if ($verb == "") {
$verb = self::constructVerb($item);
$body = self::formatPicturePost($item['body']);
- if ($item['title'] != "") {
+ if (!empty($item['title']) && !$feed_mode) {
$body = "[b]".$item['title']."[/b]\n\n".$body;
}
* @param integer $max_items Number of maximum items to fetch
* @param string $filter Feed items filter (activity, posts or comments)
* @param boolean $nocache Wether to bypass caching
+ * @param boolean $feed_mode Behave like a regular feed for users if true
*
* @return string XML feed
*/
- public static function feed($owner_nick, &$last_update, $max_items = 300, $filter = 'activity', $nocache = false)
+ public static function feed($owner_nick, &$last_update, $max_items = 300, $filter = 'activity', $nocache = false, $feed_mode = false)
{
$stamp = microtime(true);
if (Config::get('system', 'ostatus_debug')) {
$item['body'] .= '🍼';
}
- $entry = self::entry($doc, $item, $owner);
+
+ $entry = self::entry($doc, $item, $owner, false, $feed_mode);
$root->appendChild($entry);
if ($last_update < $item['created']) {