Remove unused code

- Remove commented code
- Remove unused/immediately overwritten variables
- Remove extraneous parameters
- Remove unreachable code
- Remove duplicate array keys
This commit is contained in:
Hypolite Petovan 2019-01-07 12:09:10 -05:00
parent 0c4f8277e6
commit 4a95ca280d
42 changed files with 43 additions and 218 deletions

View file

@ -748,8 +748,6 @@ class Diaspora
Logger::log("Unknown message type ".$type);
return false;
}
return true;
}
/**
@ -2354,8 +2352,6 @@ class Diaspora
*/
private static function receiveRequestMakeFriend(array $importer, array $contact)
{
$a = \get_app();
if ($contact["rel"] == Contact::SHARING) {
DBA::update(
'contact',
@ -2415,7 +2411,7 @@ class Diaspora
$user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]);
if (DBA::isResult($user)) {
Logger::log("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], Logger::DEBUG);
$ret = self::sendShare($user, $contact);
self::sendShare($user, $contact);
}
}
return true;
@ -2449,7 +2445,7 @@ class Diaspora
$batch = (($ret["batch"]) ? $ret["batch"] : implode("/", array_slice(explode("/", $ret["url"]), 0, 3))."/receive/public");
$r = q(
q(
"INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`nurl`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
VALUES (%d, '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d)",
intval($importer["uid"]),
@ -2489,7 +2485,7 @@ class Diaspora
$hash = Strings::getRandomHex().(string)time(); // Generate a confirm_key
$ret = q(
q(
"INSERT INTO `intro` (`uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
VALUES (%d, %d, %d, %d, '%s', '%s', '%s')",
intval($importer["uid"]),
@ -2520,7 +2516,7 @@ class Diaspora
$new_relation = Contact::FOLLOWER;
}
$r = q(
q(
"UPDATE `contact` SET `rel` = %d,
`name-date` = '%s',
`uri-date` = '%s',
@ -2538,7 +2534,7 @@ class Diaspora
$user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]);
if (DBA::isResult($user)) {
Logger::log("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], Logger::DEBUG);
$ret = self::sendShare($user, $contact_record);
self::sendShare($user, $contact_record);
// Send the profile data, maybe it weren't transmitted before
self::sendProfile($importer["uid"], [$contact_record]);
@ -3127,8 +3123,6 @@ class Diaspora
*/
public static function transmit(array $owner, array $contact, $envelope, $public_batch, $queue_run = false, $guid = "", $no_queue = false)
{
$a = \get_app();
$enabled = intval(Config::get("system", "diaspora_enabled"));
if (!$enabled) {
return 200;
@ -3871,15 +3865,14 @@ class Diaspora
// Remove the handle
$handle = array_pop($signed_parts);
// Glue the parts together
$text = implode(";", $signed_parts);
$message = ["author" => $handle,
"guid" => $guid,
"parent_guid" => $parent_guid,
"text" => implode(";", $signed_parts),
"author_signature" => $item['signature'],
"parent_author_signature" => ""];
$message = [
"author" => $handle,
"guid" => $guid,
"parent_guid" => $parent_guid,
"text" => implode(";", $signed_parts),
"author_signature" => $item['signature'],
"parent_author_signature" => ""
];
}
return $message;
}
@ -3996,14 +3989,6 @@ class Diaspora
return;
}
$conv = [
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
"participants" => $cnv["recips"]
];
$body = BBCode::toMarkdown($item["body"]);
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
@ -4020,12 +4005,13 @@ class Diaspora
$type = "message";
} else {
$message = [
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
"participants" => $cnv["recips"],
"message" => $msg];
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
"participants" => $cnv["recips"],
"message" => $msg
];
$type = "conversation";
}