Replaced all preg calls in the calls with the new function
This commit is contained in:
parent
eeb8bee1b7
commit
4e77321be8
|
@ -1401,23 +1401,12 @@ class Transmitter
|
||||||
*/
|
*/
|
||||||
public static function getAnnounceArray($item)
|
public static function getAnnounceArray($item)
|
||||||
{
|
{
|
||||||
if (!preg_match("/(.*?)\[share(.*?)\]\s?.*?\s?\[\/share\]\s?/ism", $item['body'], $matches)) {
|
$reshared = Item::getShareArray($item);
|
||||||
|
if (empty($reshared['guid'])) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$attributes = $matches[2];
|
$reshared_item = Item::selectFirst([], ['guid' => $reshared['guid']]);
|
||||||
$comment = $matches[1];
|
|
||||||
|
|
||||||
preg_match("/guid='(.*?)'/ism", $attributes, $matches);
|
|
||||||
if (empty($matches[1])) {
|
|
||||||
preg_match('/guid="(.*?)"/ism', $attributes, $matches);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($matches[1])) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$reshared_item = Item::selectFirst([], ['guid' => $matches[1]]);
|
|
||||||
if (!DBA::isResult($reshared_item)) {
|
if (!DBA::isResult($reshared_item)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -1431,7 +1420,7 @@ class Transmitter
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['object' => $reshared_item, 'actor' => $profile, 'comment' => trim($comment)];
|
return ['object' => $reshared_item, 'actor' => $profile, 'comment' => $reshared['comment']];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3391,69 +3391,37 @@ class Diaspora
|
||||||
{
|
{
|
||||||
$body = trim($body);
|
$body = trim($body);
|
||||||
|
|
||||||
|
$reshared = Item::getShareArray(['body' => $body]);
|
||||||
|
if (empty($reshared)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip if it isn't a pure repeated messages
|
// Skip if it isn't a pure repeated messages
|
||||||
// Does it start with a share?
|
// Does it start with a share?
|
||||||
if ((strpos($body, "[share") > 0) && $complete) {
|
if (!empty($reshared['comment']) && $complete) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does it end with a share?
|
if (!empty($reshared['guid']) && $complete) {
|
||||||
if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
|
$condition = ['guid' => $reshared['guid'], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
|
|
||||||
// Skip if there is no shared message in there
|
|
||||||
if ($body == $attributes) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't do the complete check we quit here
|
|
||||||
|
|
||||||
$guid = "";
|
|
||||||
preg_match("/guid='(.*?)'/ism", $attributes, $matches);
|
|
||||||
if (!empty($matches[1])) {
|
|
||||||
$guid = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match('/guid="(.*?)"/ism', $attributes, $matches);
|
|
||||||
if (!empty($matches[1])) {
|
|
||||||
$guid = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($guid != "") && $complete) {
|
|
||||||
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
|
||||||
$item = Item::selectFirst(['contact-id'], $condition);
|
$item = Item::selectFirst(['contact-id'], $condition);
|
||||||
if (DBA::isResult($item)) {
|
if (DBA::isResult($item)) {
|
||||||
$ret = [];
|
$ret = [];
|
||||||
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
|
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
|
||||||
$ret["root_guid"] = $guid;
|
$ret["root_guid"] = $reshared['guid'];
|
||||||
return $ret;
|
return $ret;
|
||||||
} elseif ($complete) {
|
} elseif ($complete) {
|
||||||
// We are resharing something that isn't a DFRN or Diaspora post.
|
// We are resharing something that isn't a DFRN or Diaspora post.
|
||||||
// So we have to return "false" on "$complete" to not trigger a reshare.
|
// So we have to return "false" on "$complete" to not trigger a reshare.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} elseif (($guid == "") && $complete) {
|
} elseif (empty($reshared['guid']) && $complete) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret["root_guid"] = $guid;
|
|
||||||
|
|
||||||
$profile = "";
|
|
||||||
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
|
|
||||||
if (!empty($matches[1])) {
|
|
||||||
$profile = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
|
|
||||||
if (!empty($matches[1])) {
|
|
||||||
$profile = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ret = [];
|
$ret = [];
|
||||||
|
|
||||||
if (!empty($profile) && ($cid = Contact::getIdForURL($profile))) {
|
if (!empty($reshared['profile']) && ($cid = Contact::getIdForURL($reshared['profile']))) {
|
||||||
$contact = DBA::selectFirst('contact', ['addr'], ['id' => $cid]);
|
$contact = DBA::selectFirst('contact', ['addr'], ['id' => $cid]);
|
||||||
if (!empty($contact['addr'])) {
|
if (!empty($contact['addr'])) {
|
||||||
$ret['root_handle'] = $contact['addr'];
|
$ret['root_handle'] = $contact['addr'];
|
||||||
|
|
|
@ -1199,37 +1199,12 @@ class OStatus
|
||||||
*/
|
*/
|
||||||
private static function getResharedGuid(array $item)
|
private static function getResharedGuid(array $item)
|
||||||
{
|
{
|
||||||
$body = trim($item["body"]);
|
$reshared = Item::getShareArray($item);
|
||||||
|
if (empty($reshared['guid']) || !empty($reshared['comment'])) {
|
||||||
// Skip if it isn't a pure repeated messages
|
return '';
|
||||||
// Does it start with a share?
|
|
||||||
if (strpos($body, "[share") > 0) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does it end with a share?
|
return $reshared['guid'];
|
||||||
if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
|
|
||||||
// Skip if there is no shared message in there
|
|
||||||
if ($body == $attributes) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$guid = "";
|
|
||||||
preg_match("/guid='(.*?)'/ism", $attributes, $matches);
|
|
||||||
if (!empty($matches[1])) {
|
|
||||||
$guid = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match('/guid="(.*?)"/ism', $attributes, $matches);
|
|
||||||
if (!empty($matches[1])) {
|
|
||||||
$guid = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $guid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user