Compare commits

...

3 Commits

Author SHA1 Message Date
5d9d8ed72a Strip from the last tearline when posting to matrix
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 47s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m55s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
2024-09-09 20:29:17 +10:00
eafd203021 Improve node idle detection, including adding NODE_KEEP 2024-09-09 20:16:14 +10:00
9d06b422e0 Improve match of messages that come via matrix, so they dont get posted back 2024-09-09 19:44:14 +10:00
4 changed files with 24 additions and 34 deletions

View File

@ -176,41 +176,28 @@ class AddressIdle implements ShouldQueue
$age = Carbon::now()->subDays($days)->endOfDay(); $age = Carbon::now()->subDays($days)->endOfDay();
return Address::select([ return Address::select([
'a.id', 'addresses.id',
'a.system_id', 'system_id',
'a.zone_id', 'zone_id',
'addresses.region_id', 'region_id',
'a.host_id', 'host_id',
'a.node_id', 'node_id',
'a.point_id', 'point_id',
'addresses.active', 'addresses.active',
'addresses.hub_id', 'hub_id',
'addresses.role', 'role',
'addresses.updated_at', 'addresses.updated_at',
DB::raw('sum(a.uncollected_echomail) as uncollected_echomail'),
DB::raw('sum(a.uncollected_netmail) as uncollected_netmail'),
DB::raw('sum(a.uncollected_files) as uncollected_files')
]) ])
->from( ->activeFTN()
Address::UncollectedEchomailTotal()
->union(Address::UncollectedNetmailTotal())
->union(Address::UncollectedFilesTotal()),'a')
->where('systems.active',TRUE) ->where('systems.active',TRUE)
->where('addresses.active',TRUE) ->where(fn($query)=>$query->where('point_id',0)->orWhereNull('point_id'))
->where('zones.active',TRUE) ->whereIn('addresses.id',our_nodes($do)->pluck('id'))
->where('domains.active',TRUE)
->where(fn($query)=>$query->where('a.point_id',0)->orWhereNull('a.point_id'))
->whereNotIn('a.id',our_address()->pluck('id'))
->when($ao,fn($query)=>$query->where('addresses.id',$ao->id)) ->when($ao,fn($query)=>$query->where('addresses.id',$ao->id))
->where('last_session','<',$age) ->where(fn($q)=>$q->where('last_session','<',$age)->orWhereNull('last_session'))
->where('domains.id',$do->id) ->whereRaw(sprintf('((role IS NULL) OR (role=0) OR ((role & %d) > 0))',$flags))
->whereRaw(sprintf('((role IS NULL) OR ((role & %d) > 0))',$flags)) ->whereRaw(sprintf('((role & %d) = 0)',Address::NODE_KEEP))
->join('addresses',['addresses.id'=>'a.id']) ->join('systems',['systems.id'=>'addresses.system_id'])
->join('systems',['systems.id'=>'a.system_id'])
->join('zones',['zones.id'=>'addresses.zone_id'])
->join('domains',['domains.id'=>'zones.domain_id'])
->ftnOrder() ->ftnOrder()
->groupBy('a.system_id','a.id','a.zone_id','addresses.region_id','a.host_id','a.node_id','a.point_id','addresses.hub_id','addresses.role','addresses.active','addresses.updated_at')
->with(['system','zone.domain']) ->with(['system','zone.domain'])
->dontCache() ->dontCache()
->get(); ->get();

View File

@ -29,7 +29,7 @@ class EchomailListener implements ShouldQueue
$ea = $event->eo->echoarea; $ea = $event->eo->echoarea;
// Catch our messages that we've posted, so they dont go back // Catch our messages that we've posted, so they dont go back
if (str_ends_with($event->eo->from,':'.config('matrix.server'))) if (preg_match('/^@.+:/',$event->eo->from))
return; return;
if ($ea && collect(config('matrix.rooms'))->contains($ea->name)) { if ($ea && collect(config('matrix.rooms'))->contains($ea->name)) {

View File

@ -52,9 +52,10 @@ class Address extends Model
public const NODE_HC = 1<<3; // Hub public const NODE_HC = 1<<3; // Hub
public const NODE_NN = 1<<4; // Node public const NODE_NN = 1<<4; // Node
public const NODE_PVT = 1<<5; // Pvt (we dont have address information) @todo public const NODE_PVT = 1<<5; // Pvt (we dont have address information) @todo
public const NODE_HOLD = 1<<6; // Hold (user has requested hold, we havent heard from the node for 7 days @todo public const NODE_HOLD = 1<<6; // Hold (user has requested hold, we havent heard from the node for 7 days
public const NODE_DOWN = 1<<7; // Down we havent heard from the node for 30 days @todo public const NODE_DOWN = 1<<7; // Down we havent heard from the node for 30 days
public const NODE_POINT = 1<<8; // Point public const NODE_POINT = 1<<8; // Point
public const NODE_KEEP = 1<<9; // Dont mark an address hold/down or de-list automatically
public const NODE_UNKNOWN = 1<<15; // Unknown public const NODE_UNKNOWN = 1<<15; // Unknown
public const NODE_ALL = 0x811f; // Mask to catch all nodes, excluding their status public const NODE_ALL = 0x811f; // Mask to catch all nodes, excluding their status

View File

@ -59,13 +59,15 @@ class Echomail extends Matrix
Log::error(sprintf('%s:! Failed to set matrix room topic to [%s] in room [%s]',self::LOGKEY,$x,$room),['msg'=>$topic->body()]); Log::error(sprintf('%s:! Failed to set matrix room topic to [%s] in room [%s]',self::LOGKEY,$x,$room),['msg'=>$topic->body()]);
} }
$omsg = preg_replace("/\r---.*$/U",'',$this->o->msg);
$msg = Http::withToken(config('matrix.as_token')) $msg = Http::withToken(config('matrix.as_token'))
->withQueryParameters(['user_id'=>$user]) ->withQueryParameters(['user_id'=>$user])
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/send/m.room.message',config('matrix.server'),$room),[ ->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/send/m.room.message',config('matrix.server'),$room),[
'msgtype'=>'m.text', 'msgtype'=>'m.text',
'format'=>'org.matrix.custom.html', 'format'=>'org.matrix.custom.html',
'body'=>mb_convert_encoding(str_replace("\r","\n",$this->o->msg),'UTF-8','IBM850'), 'body'=>mb_convert_encoding(str_replace("\r","\n",$omsg),'UTF-8','IBM850'),
'formatted_body'=>sprintf("<pre>\n%s\n</pre>",mb_convert_encoding(str_replace("\r","\n",$this->o->msg),'UTF-8','IBM850')), 'formatted_body'=>sprintf("<pre>\n%s\n</pre>",mb_convert_encoding(str_replace("\r","\n",$omsg),'UTF-8','IBM850')),
]); ]);
switch ($msg->status()) { switch ($msg->status()) {