use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Mail;
+use Friendica\Model\Notify;
use Friendica\Model\Notify\Type;
use Friendica\Model\PermissionSet;
use Friendica\Model\Post;
$msg["from-photo"] = XML::getFirstValue($xpath, "dfrn:sender/dfrn:avatar/text()", $mail);
$msg["contact-id"] = $importer["id"];
$msg["uri"] = XML::getFirstValue($xpath, "dfrn:id/text()", $mail);
- $msg["thr-parent"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
+ $msg["parent-uri"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
$msg["created"] = DateTimeFormat::utc(XML::getFirstValue($xpath, "dfrn:sentdate/text()", $mail));
$msg["title"] = XML::getFirstValue($xpath, "dfrn:subject/text()", $mail);
$msg["body"] = XML::getFirstValue($xpath, "dfrn:content/text()", $mail);
}
if ($Blink && Strings::compareLink($Blink, DI::baseUrl() . "/profile/" . $importer["nickname"])) {
- $author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
+ $author = DBA::selectFirst('contact', ['id', 'name', 'thumb', 'url'], ['id' => $item['author-id']]);
$parent = Item::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]);
$item['parent'] = $parent['id'];
// send a notification
notification(
[
- "type" => Type::POKE,
- "notify_flags" => $importer["notify-flags"],
- "language" => $importer["language"],
- "to_name" => $importer["username"],
- "to_email" => $importer["email"],
- "uid" => $importer["importer_uid"],
- "item" => $item,
- "link" => DI::baseUrl()."/display/".urlencode($item['guid']),
- "source_name" => $author["name"],
- "source_link" => $author["url"],
- "source_photo" => $author["thumb"],
- "verb" => $item["verb"],
- "otype" => "person",
- "activity" => $verb,
- "parent" => $item['parent']]
+ "type" => Type::POKE,
+ "otype" => Notify\ObjectType::PERSON,
+ "activity" => $verb,
+ "verb" => $item["verb"],
+ "uid" => $importer["importer_uid"],
+ "cid" => $author["id"],
+ "item" => $item,
+ "link" => DI::baseUrl() . "/display/" . urlencode($item['guid']),
+ ]
);
}
}
* @throws \ImagickException
* @todo Add type-hints
*/
- private static function processEntry($header, $xpath, $entry, $importer, $xml)
+ private static function processEntry($header, $xpath, $entry, $importer, $xml, $protocol)
{
Logger::log("Processing entries");
$item = $header;
- $item["protocol"] = Conversation::PARCEL_DFRN;
+ $item["protocol"] = $protocol;
$item["source"] = $xml;
* @throws \ImagickException
* @todo set proper type-hints
*/
- public static function import($xml, $importer, $sort_by_date = false)
+ public static function import($xml, $importer, $sort_by_date = false, $protocol = Conversation::PARCEL_DFRN)
{
if ($xml == "") {
return 400;
}
$deletions = $xpath->query("/atom:feed/at:deleted-entry");
- foreach ($deletions as $deletion) {
- self::processDeletion($xpath, $deletion, $importer);
+ if (!empty($deletions)) {
+ foreach ($deletions as $deletion) {
+ self::processDeletion($xpath, $deletion, $importer);
+ }
+ if (count($deletions) > 0) {
+ Logger::notice('Deletions had been processed');
+ return 200;
+ }
}
if (!$sort_by_date) {
$entries = $xpath->query("/atom:feed/atom:entry");
foreach ($entries as $entry) {
- self::processEntry($header, $xpath, $entry, $importer, $xml);
+ self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol);
}
} else {
$newentries = [];
ksort($newentries);
foreach ($newentries as $entry) {
- self::processEntry($header, $xpath, $entry, $importer, $xml);
+ self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol);
}
}
Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG);