From be1ef4b2930f21fe460194f51068908e18aaf8da Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 15 Jun 2024 15:29:00 +1000 Subject: [PATCH] Remove deprecated methods --- app/Classes/FTN/Message.php | 14 -------- app/Classes/FTN/Packet.php | 54 ---------------------------- app/Classes/Protocol/Binkp.php | 35 ------------------ app/Models/Address.php | 66 +--------------------------------- app/Models/User.php | 14 ++++---- 5 files changed, 8 insertions(+), 175 deletions(-) diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index a56eff2..bdc07cd 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -93,9 +93,6 @@ class Message extends FTNBase private Echomail|Netmail $mo; // The object storing this packet message private Address $us; // Our address for this message - /** @deprecated Not sure why this is needed? */ - public bool $packed = FALSE; // Has the message been packed successfully - // Convert characters into printable chars // https://int10h.org/oldschool-pc-fonts/readme/#437_charset private const CP437 = [ @@ -379,17 +376,6 @@ class Message extends FTNBase case 'tftn': return parent::__get($key); - // For 5D we need to include the domain - /* @deprecated - is this required? */ - case 'fboss': - return sprintf('%d:%d/%d',$this->fz,$this->fn,$this->ff).(($x=$this->fdomain) ? '@'.$x->name : ''); - case 'tboss': - return sprintf('%d:%d/%d',$this->tz,$this->tn,$this->tf).(($x=$this->tdomain) ? '@'.$x->name : ''); - case 'fboss_o': - return Address::findFTN($this->fboss); - case 'tboss_o': - return Address::findFTN($this->tboss); - // Convert our message (header[datetime]) with our TZUTC into a Carbon date case 'datetime': try { diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index f76f7fa..34ba3f7 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -340,53 +340,6 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable /* METHODS */ - /** - * When creating a new packet, set the header. - * - * @param Address $oo - * @param Address $o - * @param string|null $passwd Override the password used in the packet - * @deprecated Use Packet::generate(), which should generate a packet of the right type - */ - public function addressHeader(Address $oo,Address $o,string $passwd=NULL): void - { - Log::debug(sprintf('%s:+ Creating packet for [%s]',self::LOGKEY,$o->ftn)); - - $date = Carbon::now(); - - // Create Header - $this->header = [ - 'ozone' => $oo->zone->zone_id, // Orig Zone - 'dzone' => $o->zone->zone_id, // Dest Zone - 'onet' => $oo->host_id ?: $oo->region_id, // Orig Net - 'dnet' => $o->host_id ?: $o->region_id, // Dest Net - 'onode' => $oo->node_id, // Orig Node - 'dnode' => $o->node_id, // Dest Node - 'opoint' => $oo->point_id, // Orig Point - 'dpoint' => $o->point_id, // Dest Point - 'odomain' => $oo->zone->domain->name, // Orig Domain - 'ddomain' => $o->zone->domain->name, // Dest Domain - 'y' => $date->format('Y'), // Year - 'm' => $date->format('m')-1, // Month - 'd' => $date->format('d'), // Day - 'H' => $date->format('H'), // Hour - 'M' => $date->format('i'), // Minute - 'S' => $date->format('s'), // Second - 'password' => strtoupper((! is_null($passwd)) ? $passwd : $o->pass_packet), // Packet Password - ]; - } - - /** - * Add a message to this packet - * - * @param Message $o - * @deprecated No longer used when Address::class is updated - */ - public function addMail(Message $o): void - { - $this->messages->push($o); - } - public function for(Address $ao): self { $this->tftn_p = $ao; @@ -509,11 +462,4 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable return $this; } - - /** @deprecated Is this used? */ - public function pluck(string $key): Collection - { - throw new \Exception(sprintf('%s:! This function is deprecated - [%s]',self::LOGKEY,$key)); - return $this->messages->pluck($key); - } } \ No newline at end of file diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index 4206a13..1ae3a76 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -1540,25 +1540,6 @@ final class Binkp extends BaseProtocol } } - /** - * Strip blanks at the beginning of a string - * - * @param string $str - * @return string - * @throws \Exception - * @deprecated - use ltrim instead - */ - private function skip_blanks(string $str): string - { - $c = 0; - - if ($str != NULL) - while ($this->isSpace(substr($str,$c,1))) - $c++; - - return substr($str,$c); - } - /** * Return the string delimited by char and shorten the input to the remaining characters * @@ -1579,20 +1560,4 @@ final class Binkp extends BaseProtocol return $return; } - - /** - * Check if the string is a space - * - * @param string $str - * @return bool - * @throws \Exception - * @deprecated No longer required since we are using ltrim - */ - private function isSpace(string $str):bool - { - if (strlen($str) > 1) - throw new \Exception('String is more than 1 char'); - - return $str && in_array($str,[' ',"\n","\r","\v","\f","\t"]); - } } \ No newline at end of file diff --git a/app/Models/Address.php b/app/Models/Address.php index 9ada429..033dd07 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -566,21 +566,6 @@ class Address extends Model ->withPivot(['export_at','sent_at','sent_pkt']); } - /** - * @deprecated use echomail_seen() - */ - public function echomails() { - return $this->echomail_seen(); - } - - /** - * @deprecated use file_seen - */ - public function files() - { - return $this->file_seen(); - } - /** * Files that this address has seen * @@ -1036,7 +1021,7 @@ class Address extends Model */ public function filesWaiting(): Collection { - return $this->files() + return $this->file_seen() ->whereNull('sent_at') ->whereNotNull('export_at') ->get(); @@ -1104,18 +1089,6 @@ class Address extends Model return NULL; } - /** - * Get files for this node (including it's children) - * - * @param bool $update - * @return Collection - * @deprecated use filesWaiting() directly - */ - public function getFiles(bool $update=TRUE): Collection - { - return $this->filesWaiting(); - } - /** * Get netmail for this node (including it's children) * @@ -1162,43 +1135,6 @@ class Address extends Model return NULL; } - /** - * Return a packet of mail - * - * @param Collection $msgs of message models (Echomail/Netmail) - * @param string|null $passwd Override password used in packet - * @return Packet|null - * @throws \Exception - * @deprecated - */ - private function getPacket(Collection $msgs,string $passwd=NULL): ?Packet - { - $s = Setup::findOrFail(config('app.id')); - $ao = our_address($this); - - // If we dont match on the address, we cannot pack mail for that system - if (! $ao) { - Log::alert(sprintf('%s:! We didnt match an address in zone [%d] for [%s]',self::LOGKEY,$this->zone->zone_id,$this->ftn)); - return NULL; - } - - // Get packet type - $o = $ao->system->packet($this); - $o->addressHeader($ao,$this,$passwd); - - // $oo = Netmail/Echomail Model - $c = 0; - foreach ($msgs as $oo) { - // Only bundle up to max messages - if (++$c > $s->pkt_msgs) - break; - - $o->addMail($oo->packet($this,$passwd)); - } - - return $o; - } - public function isRoleOverride(int $role=NULL): bool { $val = ($this->role & self::NODE_ALL); diff --git a/app/Models/User.php b/app/Models/User.php index efdaab8..0df3cf5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -102,17 +102,17 @@ class User extends Authenticatable implements MustVerifyEmail } /** + * Does this user have systems with points + * * @return Collection - * @deprecated not used - but if it is, probably could use Address::points()? */ public function points(): Collection { - $result = collect(); - - foreach($this->systems->pluck('addresses')->flatten()->where('role','>',Address::NODE_HC) as $ao) - $result = $result->merge($ao->children()); - - return $result; + return $this + ->systems + ->pluck('addresses') + ->flatten() + ->where('point_id','>',0); } /**