[TheFreeNetwork][fix_duplicates.php] Don't die because you couldn't federate an undo follow
This commit is contained in:
parent
7d52440461
commit
09c3236afc
|
@ -80,25 +80,35 @@ function fix_duplicates(string $profile_class, array &$seen): void
|
||||||
|
|
||||||
// Have we seen this profile before?
|
// Have we seen this profile before?
|
||||||
if (array_key_exists($uri, $seen)) {
|
if (array_key_exists($uri, $seen)) {
|
||||||
// Was it on a previous protocol? Keep the highest preference protocol's one
|
try {
|
||||||
if ($seen[$uri] !== $id) {
|
// Was it on a previous protocol? Keep the highest preference protocol's one
|
||||||
printfnq("Deleting Profile with id = {$id}\n");
|
if ($seen[$uri] !== $id) {
|
||||||
$profile = Profile::getByID($id);
|
printfnq("Deleting Profile with id = {$id}\n");
|
||||||
$profile->delete();
|
$profile = Profile::getByID($id);
|
||||||
} else {
|
$profile->delete();
|
||||||
printfnq("Deleting {$profile_class} with id = {$id}\n");
|
} else {
|
||||||
$protocol_profile->delete();
|
printfnq("Deleting {$profile_class} with id = {$id}\n");
|
||||||
|
$protocol_profile->delete();
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Let it go
|
||||||
|
printfnq('FWIW: ' . $e->getMessage() . "\n");
|
||||||
}
|
}
|
||||||
} elseif (array_key_exists($uri, $seen_local)) {
|
} elseif (array_key_exists($uri, $seen_local)) {
|
||||||
// Was it in this protocol? Delete the older record.
|
try {
|
||||||
if ($seen_local[$uri] !== $id) {
|
// Was it in this protocol? Delete the older record.
|
||||||
printfnq("Deleting Profile with id = {$seen_local[$uri]}\n");
|
if ($seen_local[$uri] !== $id) {
|
||||||
$profile = Profile::getByID($seen_local[$uri]);
|
printfnq("Deleting Profile with id = {$seen_local[$uri]}\n");
|
||||||
$profile->delete();
|
$profile = Profile::getByID($seen_local[$uri]);
|
||||||
} else {
|
$profile->delete();
|
||||||
printfnq("Deleting {$profile_class} with id = {$seen_local[$uri]}\n");
|
} else {
|
||||||
$profile = $profile_class::getKV('profile_id', $seen_local[$uri]);
|
printfnq("Deleting {$profile_class} with id = {$seen_local[$uri]}\n");
|
||||||
$profile->delete();
|
$profile = $profile_class::getKV('profile_id', $seen_local[$uri]);
|
||||||
|
$profile->delete();
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Let it go
|
||||||
|
printfnq('FWIW: ' . $e->getMessage() . "\n");
|
||||||
}
|
}
|
||||||
// Update the profile id for this URI.
|
// Update the profile id for this URI.
|
||||||
$seen_local[$uri] = $id;
|
$seen_local[$uri] = $id;
|
||||||
|
@ -107,6 +117,8 @@ function fix_duplicates(string $profile_class, array &$seen): void
|
||||||
$seen_local[$uri] = $id;
|
$seen_local[$uri] = $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$protocol_profile->free();
|
||||||
|
unset($protocol_profile);
|
||||||
|
|
||||||
// Merge the findings inside this protocol with the global seen to be used on the next protocol of the list.
|
// Merge the findings inside this protocol with the global seen to be used on the next protocol of the list.
|
||||||
$seen = array_merge($seen, $seen_local);
|
$seen = array_merge($seen, $seen_local);
|
||||||
|
|
|
@ -710,7 +710,7 @@ class OStatusPlugin extends Plugin
|
||||||
* @param Profile $profile subscriber
|
* @param Profile $profile subscriber
|
||||||
* @param Profile $other subscribee
|
* @param Profile $other subscribee
|
||||||
*
|
*
|
||||||
* @return hook return code
|
* @return bool hook return code
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@ -735,7 +735,7 @@ class OStatusPlugin extends Plugin
|
||||||
* @param Profile $profile subscriber
|
* @param Profile $profile subscriber
|
||||||
* @param Profile $other subscribee
|
* @param Profile $other subscribee
|
||||||
*
|
*
|
||||||
* @return hook return code
|
* @return bool hook return code
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -385,7 +385,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @param mixed $entry XML string, Notice, or Activity
|
* @param mixed $entry XML string, Notice, or Activity
|
||||||
* @param Profile $actor
|
* @param Profile $actor
|
||||||
* @return boolean success
|
* @return bool success
|
||||||
*/
|
*/
|
||||||
public function notifyActivity($entry, Profile $actor)
|
public function notifyActivity($entry, Profile $actor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,11 +43,16 @@ class Salmon
|
||||||
*
|
*
|
||||||
* @param string $endpoint_uri
|
* @param string $endpoint_uri
|
||||||
* @param string $xml string representation of payload
|
* @param string $xml string representation of payload
|
||||||
* @param Profile $user profile whose keys we sign with (must be a local user)
|
* @param Profile $actor profile whose keys we sign with (must be a local user)
|
||||||
* @return boolean success
|
* @param Profile|null $target
|
||||||
|
* @return bool success
|
||||||
*/
|
*/
|
||||||
public static function post($endpoint_uri, $xml, Profile $actor, Profile $target=null)
|
public static function post(
|
||||||
{
|
$endpoint_uri,
|
||||||
|
$xml,
|
||||||
|
Profile $actor,
|
||||||
|
?Profile $target = null
|
||||||
|
) {
|
||||||
if (empty($endpoint_uri)) {
|
if (empty($endpoint_uri)) {
|
||||||
common_debug('No endpoint URI for Salmon post to '.$actor->getUri());
|
common_debug('No endpoint URI for Salmon post to '.$actor->getUri());
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user