add join role endpoint and persistency for hubs

This commit is contained in:
2026-05-06 19:08:18 +02:00
parent 03c13a6e8a
commit f68a249268
12 changed files with 991 additions and 206 deletions
+41 -3
View File
@@ -69,6 +69,8 @@
<button data-form="hub-channel-role-view" onclick="showForm('hub-channel-role-view')">PATCH /hub/channel/roles/view</button>
<button data-form="hub-channel-role-send" onclick="showForm('hub-channel-role-send')">PATCH /hub/channel/roles/send</button>
<button data-form="hub-channel-role-history" onclick="showForm('hub-channel-role-history')">PATCH /hub/channel/roles/history</button>
<button data-form="hub-channel-set-icon" onclick="showForm('hub-channel-set-icon')">PATCH /hub/channel/icon</button>
<button data-form="get-hub-channel-icon" onclick="showForm('get-hub-channel-icon')">GET /hub/channel/icon</button>
<button data-form="hub-user-add-role" onclick="showForm('hub-user-add-role')">PUT /hub/user/role</button>
<button data-form="hub-role-create" onclick="showForm('hub-role-create')">PUT /hub/role</button>
<button data-form="hub-channel-create" onclick="showForm('hub-channel-create')">PUT /hub/channel</button>
@@ -108,7 +110,7 @@
<!-- POST /file -->
<div class="form-content" id="fc-file-upload">
<div class="field"><label>token</label><input id="fu-token" placeholder=""></div>
<div class="field"><label>connectionid</label><input id="fu-connectionid" placeholder="UUID"></div>
<div class="field"><label>target_id</label><input id="fu-connectionid" placeholder="UUID (connection or channel)"></div>
<div class="field"><label>file</label><input id="fu-file" type="file"></div>
<div class="form-actions"><button class="send" onclick="submitFileUpload()">Send</button></div>
</div>
@@ -320,6 +322,23 @@
<div class="form-actions"><button class="send" onclick="submit('get-hub-bg')">Send</button></div>
</div>
<!-- PATCH /hub/channel/icon -->
<div class="form-content" id="fc-hub-channel-set-icon">
<div class="field"><label>token</label><input id="hcsi-token" placeholder=""></div>
<div class="field"><label>hubid</label><input id="hcsi-hubid" placeholder="UUID"></div>
<div class="field"><label>channel_id</label><input id="hcsi-channelid" placeholder="UUID"></div>
<div class="field"><label>file</label><input id="hcsi-file" type="file"></div>
<div class="form-actions"><button class="send" onclick="submitChannelIconUpload()">Send</button></div>
</div>
<!-- GET /hub/channel/icon -->
<div class="form-content" id="fc-get-hub-channel-icon">
<div class="field"><label>token</label><input id="ghci-token" placeholder=""></div>
<div class="field"><label>hubid</label><input id="ghci-hubid" placeholder="UUID"></div>
<div class="field"><label>channel_id</label><input id="ghci-channelid" placeholder="UUID"></div>
<div class="form-actions"><button class="send" onclick="submit('get-hub-channel-icon')">Send</button></div>
</div>
<!-- DELETE /hub -->
<div class="form-content" id="fc-hub-remove">
<div class="field"><label>token</label><input id="hr-token" placeholder=""></div>
@@ -579,6 +598,8 @@
'get-hub-icon': { method:'GET', path:'/hub/icon', title:'GET /hub/icon — get hub icon URL', fields:[{id:'ghi-token',dest:'header',name:'token'},{id:'ghi-hubid',dest:'header',name:'hub_id'}] },
'hub-set-bg': { title:'PATCH /hub/bg — set hub background image' },
'get-hub-bg': { method:'GET', path:'/hub/bg', title:'GET /hub/bg — get hub background URL', fields:[{id:'ghbg-token',dest:'header',name:'token'},{id:'ghbg-hubid',dest:'header',name:'hub_id'}] },
'hub-channel-set-icon': { title:'PATCH /hub/channel/icon — set channel icon image' },
'get-hub-channel-icon': { method:'GET', path:'/hub/channel/icon', title:'GET /hub/channel/icon — get channel icon URL', fields:[{id:'ghci-token',dest:'header',name:'token'},{id:'ghci-hubid',dest:'header',name:'hub_id'},{id:'ghci-channelid',dest:'query',name:'channel_id'}] },
'hub-remove': { method:'DELETE', path:'/hub', title:'DELETE /hub — remove hub', fields:[{id:'hr-token',dest:'header',name:'token'},{id:'hr-hubid',dest:'header',name:'hub_id'}] },
'hub-toggle-color': { method:'PATCH', path:'/hub/usercolorallowed', title:'PATCH /hub/usercolorallowed — toggle user color allowed', fields:[{id:'htc-token',dest:'header',name:'token'},{id:'htc-hubid',dest:'header',name:'hub_id'}] },
'hub-user-remove': { method:'DELETE', path:'/hub/user', title:'DELETE /hub/user — remove user from hub', fields:[{id:'hur-token',dest:'header',name:'token'},{id:'hur-hubid',dest:'header',name:'hub_id'},{id:'hur-targetid',dest:'query',name:'target_id'}] },
@@ -798,9 +819,9 @@
const fileInput = document.getElementById('fu-file');
if (!fileInput.files.length) { log('HTTP ERR', 'no file selected', 'log-err'); return; }
const form = new FormData();
form.append('connection_id', connectionid);
form.append('target_id', connectionid);
form.append('file', fileInput.files[0]);
log('POST /file', 'connection_id=' + connectionid + ' file=' + fileInput.files[0].name, 'log-info');
log('POST /file', 'target_id=' + connectionid + ' file=' + fileInput.files[0].name, 'log-info');
try {
const resp = await fetch(baseUrl() + '/file', { method: 'POST', headers: { token }, body: form });
const text = await resp.text();
@@ -913,6 +934,23 @@
} catch(e) { log('HTTP ERR', e.message, 'log-err'); }
}
async function submitChannelIconUpload() {
const token = document.getElementById('hcsi-token').value;
const hubid = document.getElementById('hcsi-hubid').value;
const channelid = document.getElementById('hcsi-channelid').value;
const fileInput = document.getElementById('hcsi-file');
if (!fileInput.files.length) { log('HTTP ERR', 'no file selected', 'log-err'); return; }
const form = new FormData();
form.append('channel_id', channelid);
form.append('file', fileInput.files[0]);
log('PATCH /hub/channel/icon', 'channel_id=' + channelid + ' file=' + fileInput.files[0].name, 'log-info');
try {
const resp = await fetch(baseUrl() + '/hub/channel/icon', { method: 'PATCH', headers: { token, hub_id: hubid }, body: form });
const text = await resp.text();
log('HTTP ' + resp.status, text, resp.ok ? 'log-http' : 'log-err');
} catch(e) { log('HTTP ERR', e.message, 'log-err'); }
}
async function submitGetUserProfileBg() {
const token = document.getElementById('gpb-token').value;
const userid = document.getElementById('gpb-userid').value;