Support multiple sysops and bulletin comments; complete UI translations

Allow native SYSOP accounts to sign in independently, with an optional sysopUsers allow-list and isolated browser sessions. Keep station services on the configured service account.

Add public bulletin comments that preserve category and distribution, alongside private replies to the author. Complete APRS and dynamic status translations and handle decorated button labels correctly.

Document configuration and reply behavior. Add authentication, installer, bulletin reply and translation regression coverage.
This commit is contained in:
alberto committed 2026-10-19 13:04:39 +02:00
1 parent 33f1294405
commit 2ef3c25eb3
16 files changed
+298 -23

No files matched your search

+5 -4
View File
@@ -23,7 +23,8 @@ function mailTimezone(){const minutes=-new Date().getTimezoneOffset();return 'UT
function mailTimeMeta(m){const zone=mailTimezone();const stamp=kind=>{const value=kind==='sent'?m.createdAt:m.receivedAt;return value?new Date(value).toLocaleString(BPQI18n.locale(),{day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'}):null;};return [stamp('sent')?'Inviato <b>'+esc(stamp('sent'))+'</b>':'',stamp('received')?'Ricevuto <b>'+esc(stamp('received'))+'</b>':'','Timezone: '+esc(zone)].filter(Boolean).map(x=>'<span>'+x+'</span>').join('');}
function mailRow(m,selection,attribute,options={}){const unread=!m.read&&m.status==='N',current=selection===m.id;return `<button class="message-item mail-row ${current?'selected':''} ${unread?'unread':''}" ${attribute}="${m.id}" aria-pressed="${current}" title="${esc(m.subject)}"><span class="mail-indicator" aria-label="${unread?'Non letto':'Letto'}">${unread?'●':'○'}</span><span class="mail-from" title="${esc(options.from||m.from)}">${esc(options.from||m.from)}</span><span class="mail-subject">${esc(m.subject||'(Senza oggetto)')}${m.attachmentCount?'<span class="mail-paperclip" aria-label="Allegati" title="'+m.attachmentCount+' '+BPQI18n.t('Allegati')+'">📎 '+m.attachmentCount+'</span>':''}</span><span class="mail-category">${esc(options.category||m.to)}</span><time class="mail-date" datetime="${esc(m.receivedAt||m.createdAt||'')}" title="${esc(mailDate(m,'sent'))}">${esc(mailDate(m,options.dateKind))}</time><span class="mail-size">${size(m.size)}</span><span class="mail-status">${esc(options.status||m.status)}</span></button>`;}
function renderMessages(){const q=$('#search').value.toLowerCase(),cat=$('#category').value;const list=allMessages.filter(m=>(filter==='all'||m.type===filter||filter==='sent'&&m.from.replace(/-\d+$/,'')===station.call.replace(/-\d+$/,''))&&(!cat||m.to===cat)&&(!q||`${m.subject} ${m.from} ${m.to} ${m.id}`.toLowerCase().includes(q)));$('#list-count').textContent=list.length+' messaggi';$('#message-list').innerHTML=list.map(m=>mailRow(m,selected,'data-id',{category:categoryLabel(m),status:m.status==='F'?'Inoltrato':m.status==='N'?(m.read?'Letto':'Nuovo'):m.status==='Y'?'Letto':m.status==='H'?'Trattenuto':m.status})).join('')||'<p class="empty">Nessun messaggio corrisponde ai filtri.</p>';$$('#message-list [data-id]').forEach(b=>b.onclick=()=>readMessage(Number(b.dataset.id)));}
async function readMessage(id){const generation=++loadGeneration;selected=id;renderMessages();$('#reader').innerHTML='<div class="reader-empty"><h2>Caricamento messaggio…</h2></div>';try{const m=await api('/messages/'+id);if(generation!==loadGeneration)return;$('#reader').innerHTML=`<div class="reader-header"><span class="tag">${m.type==='B'?'BOLLETTINO':'MESSAGGIO PERSONALE'} · #${id}</span><h2>${esc(m.subject)}</h2><div class="reader-meta"><span>Da <b>${esc(m.from)}</b></span><span>A <b>${esc(m.to)}</b></span>${mailTimeMeta(m)}</div></div><div class="reader-body">${readableBody(m.text)}</div><footer class="reader-footer"><span>BID ${esc(m.bid||'—')}</span><button class="secondary" id="reply">↩ Rispondi</button></footer>`;markMessageRead(id).catch(error=>toast(error.message));$('#reply').onclick=()=>openCompose({to:m.from,subject:(/^Re:/i.test(m.subject)?m.subject:'Re: '+m.subject).slice(0,80),text:'\n\n--- '+m.from+' ---\n'+m.text.split('\n').map(l=>'> '+l).join('\n')});}catch(err){$('#reader').innerHTML=`<div class="reader-empty"><h2>Messaggio non disponibile</h2><p>${esc(err.message)}</p></div>`}}
function replyDraft(message,comment=false){const bulletin=comment&&message.type==='B',destination=String((bulletin?message.to:message.from)||'').trim().replace(/\s*@\s*/g,'@'),via=String(message.via||'').trim();return {to:bulletin&&via&&!destination.includes('@')?destination+'@'+via:destination,type:bulletin?'B':'P',subject:(/^Re:/i.test(message.subject)?message.subject:'Re: '+message.subject).slice(0,80),text:'\n\n--- '+message.from+' ---\n'+message.text.split('\n').map(line=>'> '+line).join('\n')};}
async function readMessage(id){const generation=++loadGeneration;selected=id;renderMessages();$('#reader').innerHTML='<div class="reader-empty"><h2>Caricamento messaggio…</h2></div>';try{const m=await api('/messages/'+id);if(generation!==loadGeneration)return;$('#reader').innerHTML=`<div class="reader-header"><span class="tag">${m.type==='B'?'BOLLETTINO':'MESSAGGIO PERSONALE'} · #${id}</span><h2>${esc(m.subject)}</h2><div class="reader-meta"><span>Da <b>${esc(m.from)}</b></span><span>A <b>${esc(m.to)}</b></span>${mailTimeMeta(m)}</div></div><div class="reader-body">${readableBody(m.text)}</div><footer class="reader-footer"><span>BID ${esc(m.bid||'—')}</span><div class="reader-reply-actions">${m.type==='B'?'<button class="secondary" id="comment" title="Pubblica un commento come bollettino">▤ Commenta</button>':''}<button class="secondary" id="reply" title="Rispondi all’autore con un messaggio personale">↩ Rispondi</button></div></footer>`;markMessageRead(id).catch(error=>toast(error.message));$('#reply').onclick=()=>openCompose(replyDraft(m));if(m.type==='B')$('#comment').onclick=()=>openCompose(replyDraft(m,true));}catch(err){$('#reader').innerHTML=`<div class="reader-empty"><h2>Messaggio non disponibile</h2><p>${esc(err.message)}</p></div>`}}
$$('[data-filter]').forEach(b=>b.onclick=()=>{filter=b.dataset.filter;$$('[data-filter]').forEach(x=>x.classList.toggle('active',x===b));renderMessages()});$('#search').oninput=renderMessages;$('#category').onchange=renderMessages;
function openCompose(data={}){const f=$('#compose-form');f.reset();for(const [key,value]of Object.entries(data))f.elements[key].value=value;$('#compose-error').textContent='';$('#compose').showModal();f.elements.to.focus()}
$$('.compose-button').forEach(b=>b.onclick=()=>openCompose());$$('.close-compose').forEach(b=>b.onclick=()=>{const f=$('#compose-form');if((f.elements.text.value||f.elements.subject.value||window.bpqComposeAttachments?.count())&&!bpqConfirm('Chiudere e scartare questa bozza?'))return;$('#compose').close()});
@@ -37,10 +38,10 @@ function applyStation(user){
document.title='BPQ Console · '+station.nodeCall;
$('.side-station').textContent=[station.nodeCall,station.alias,station.locator].filter(Boolean).join(' · ');
$('.profile .avatar').textContent=station.call.slice(0,2);
$('.profile > div:nth-child(2)').textContent=user.name+' · '+station.call;
$('.profile > div:nth-child(2)').textContent=user.name+' · '+user.call;
$('.mission-heading h1').textContent=station.nodeCall+' / '+station.alias;
$('.mission-location').textContent=station.locator||'BPQ';
$('.modem-brand').textContent=station.radio?.name||'Nessuna porta modem';
$('.modem-brand').textContent=station.radio?.name||BPQI18n.t('Nessuna porta modem');
$('#home .page-footer').firstChild.textContent='BPQ Console · '+station.nodeCall+' ';
$('#compose .eyebrow').textContent=station.call;
$('.compose-help').textContent='Il messaggio sarà salvato nella BBS. L’inoltro segue i profili BPQ.';
@@ -60,6 +61,6 @@ function applyStation(user){
if(!station.features[page]&&['bbs','chat','winlink','monitor'].includes(page))navigate('home');
}
document.addEventListener('bpq-languagechange',()=>{if(csrf){renderMessages();if(typeof wlRender==='function')wlRender();}});
document.addEventListener('bpq-languagechange',()=>{if(csrf){if(!station.radio)$('.modem-brand').textContent=BPQI18n.t('Nessuna porta modem');renderMessages();if(typeof wlRender==='function')wlRender();}});
async function markMessageRead(id){const state=await api('/messages/'+id+'/read',{method:'POST',body:'{}'});for(const item of allMessages)if(item.id===id)Object.assign(item,state);if(typeof wlData!=='undefined'&&wlData)for(const item of wlData.messages)if(item.id===id)Object.assign(item,state);renderMessages();if(typeof wlRender==='function')wlRender();}