Align mail columns and add live sync dialogs with targeted cancellation
This commit is contained in:
1 parent
e536f0939c
commit
573e0aa24e
15 files changed
+133
-20
No files matched your search
+3
-3
@@ -22,8 +22,8 @@ export class WinlinkRadio{
|
||||
async saveNative(fields){const key=await this.fwd.context();await this.fwd.bpq('/Mail/FwdDetails?'+key,{method:'POST',body:this.job.peer});await this.fwd.bpq('/Mail/FWDSave?'+key,{method:'POST',body:profilePayload(fields)});this.fwd.cached=null;return key;}
|
||||
async currentProfile(){return rawProfile(await readFile(path.join(this.config.root,'BPQMailChat','BPQMail.cfg'),'utf8'),this.job?.peer||this.config.cmsPeer||'RMS');}
|
||||
async restore(){await this.init;return this.fwd.exclusive(async()=>{if(!this.job?.restoring)return this.snapshot();if(activeMailStreams(await this.fwd.bpq('/Mail/Status')).length)throw new Error('Attendi la fine della sessione BBS prima di ripristinare Internet');await this.saveNative(this.job.original);this.job.restoring=false;this.job.endedAt=new Date().toISOString();this.job.state='ended';this.job.error=null;this.fwd.lockedPeers.delete(this.job.peer);await this.persist();await releasePacketSlot(this);return this.snapshot();});}
|
||||
async start(id){await this.init;return this.fwd.exclusive(async()=>{
|
||||
if(this.job?.restoring)throw new Error('Una sessione Winlink radio è già in corso o in ripristino');
|
||||
async start(id,{signal}={}){await this.init;return this.fwd.exclusive(async()=>{
|
||||
signal?.throwIfAborted();if(this.job?.restoring)throw new Error('Una sessione Winlink radio è già in corso o in ripristino');
|
||||
if(!this.config.radio||!this.config.winlinkRadio?.catControl)throw new Error('Controllo frequenza CAT per Winlink radio non configurato');
|
||||
const channel=await this.directory.selected(id),peer=this.config.cmsPeer||'RMS',now=Date.now(),radio=this.fwd.radio();
|
||||
if(radio?.active||radio?.connecting)throw new Error('Modem impegnato: attendi la fine della connessione');
|
||||
@@ -34,7 +34,7 @@ export class WinlinkRadio{
|
||||
const support=channelSupport(this.config,channel.family?channel:{...channel,family:channel.mode});if(!support.supported)throw Error(support.reason);
|
||||
const temporary=radioProfile(original,channel,support.port),backup=path.join(this.config.root,'BPQMailChat','Backup-winlink-radio-'+new Date().toISOString().replace(/[:.]/g,'-'));await mkdir(backup);await copyFile(path.join(this.config.root,'BPQMailChat','BPQMail.cfg'),path.join(backup,'BPQMail.cfg'));
|
||||
this.job={peer,channel:{id:channel.id,call:channel.call,dialHz:channel.dialHz,centerHz:channel.centerHz,mode:channel.mode,grid:channel.grid},original,temporary,startedAt:new Date().toISOString(),state:'requested',restoring:true};this.fwd.lockedPeers.set(peer,'Sessione Winlink radio in corso');await this.persist();
|
||||
this.busy=true;try{if(channel.family==='Packet'&&this.config.winlinkRadio?.packetController){this.job.temporary={...original,Enabled:'0',FWDNewImmediately:'0'};this.job.state='preparing';await this.persist();await this.saveNative(this.job.temporary);await reservePacketSlot(this,this.config.winlinkRadio.packetController,channel.dialHz/1e6,support.port);if(activeMailStreams(await this.fwd.bpq('/Mail/Status')).length)throw Error('Una sessione BBS è iniziata: riprova al termine');this.job.temporary=temporary;this.job.startedAt=new Date().toISOString();this.job.state='requested';await this.persist();}const key=await this.saveNative(temporary);await this.fwd.bpq('/Mail/FwdDetails?'+key,{method:'POST',body:peer});await this.fwd.bpq('/Mail/FWDSave?'+key,{method:'POST',body:'StartForward'});this.fwd.requested.set(peer,Date.now());return this.snapshot();}catch{this.job.state='error';this.job.error='Richiesta BPQ non confermata; verifica e ripristino automatico in corso';await this.persist();throw new Error(this.job.error);}finally{this.busy=false;}
|
||||
this.busy=true;try{if(channel.family==='Packet'&&this.config.winlinkRadio?.packetController){this.job.temporary={...original,Enabled:'0',FWDNewImmediately:'0'};this.job.state='preparing';await this.persist();await this.saveNative(this.job.temporary);await reservePacketSlot(this,this.config.winlinkRadio.packetController,channel.dialHz/1e6,support.port,{signal});signal?.throwIfAborted();if(activeMailStreams(await this.fwd.bpq('/Mail/Status')).length)throw Error('Una sessione BBS è iniziata: riprova al termine');this.job.temporary=temporary;this.job.startedAt=new Date().toISOString();this.job.state='requested';await this.persist();}const key=await this.saveNative(temporary);await this.fwd.bpq('/Mail/FwdDetails?'+key,{method:'POST',body:peer});signal?.throwIfAborted();await this.fwd.bpq('/Mail/FWDSave?'+key,{method:'POST',body:'StartForward'});this.fwd.requested.set(peer,Date.now());return this.snapshot();}catch{this.job.state='error';this.job.error='Richiesta BPQ non confermata; verifica e ripristino automatico in corso';await this.persist();throw new Error(this.job.error);}finally{this.busy=false;}
|
||||
});}
|
||||
async tick(){await this.init;if(!this.job?.restoring||this.busy)return;this.busy=true;try{await this.fwd.exclusive(async()=>{
|
||||
const j=this.job,age=Date.now()-Date.parse(j.startedAt),h=forwardingHistory(await this.fwd.logs(),j.peer).find(s=>Date.parse(s.startedAt)>=Date.parse(j.startedAt)-2000),streams=activeMailStreams(await this.fwd.bpq('/Mail/Status'));
|
||||
|
||||
Reference in new issue
Block a user