Fix: Pleroma image upload

This commit is contained in:
cutls 2020-04-11 10:41:04 +09:00
parent 6ddc613b5a
commit b2564cfabb

View File

@ -133,25 +133,34 @@ async function media(b64, type, no, stamped) {
//v2/media //v2/media
try { try {
var id = await v2MediaUpload(domain, at, fd) var id = await v2MediaUpload(domain, at, fd)
var mediav = $('#media').val() if(!id) {
var regExp = new RegExp('tmp_' + r, 'g') var start = 'https://' + domain + '/api/v1/media'
mediav = mediav.replace(regExp, id) httpreq.open('POST', start, true)
$('#media').val(mediav) httpreq.upload.addEventListener('progress', progshow, false)
var html = `<img src="../../img/picture.svg" class="preview-img pointer unknown" data-media="${id}" oncontextmenu="deleteImage('${id}')" onclick="altImage('${acct_id}','${id}')" title="${lang.lang_postimg_delete}">` httpreq.responseType = 'json'
$('#preview').append(html) httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
todc() httpreq.send(fd)
if (localStorage.getItem('nsfw_' + acct_id)) { } else {
$('#nsfw').addClass('yellow-text') var mediav = $('#media').val()
$('#nsfw').html('visibility') var regExp = new RegExp('tmp_' + r, 'g')
$('#nsfw').addClass('nsfw-avail') mediav = mediav.replace(regExp, id)
} $('#media').val(mediav)
$('.toot-btn-group').prop('disabled', false) var html = `<img src="../../img/picture.svg" class="preview-img pointer unknown" data-media="${id}" oncontextmenu="deleteImage('${id}')" onclick="altImage('${acct_id}','${id}')" title="${lang.lang_postimg_delete}">`
$('select').formSelect() $('#preview').append(html)
$('#mec').text(lang.lang_there) todc()
M.toast({ html: '<span>' + lang.lang_postimg_sync + '</span><button class="btn-flat toast-action" onclick="syncDetail()">Click</button>', displayLength: 3000 }) if (localStorage.getItem('nsfw_' + acct_id)) {
$('#imgup').text('') $('#nsfw').addClass('yellow-text')
$('#imgsel').show() $('#nsfw').html('visibility')
localStorage.removeItem('image') $('#nsfw').addClass('nsfw-avail')
}
$('.toot-btn-group').prop('disabled', false)
$('select').formSelect()
$('#mec').text(lang.lang_there)
M.toast({ html: '<span>' + lang.lang_postimg_sync + '</span><button class="btn-flat toast-action" onclick="syncDetail()">Click</button>', displayLength: 3000 })
$('#imgup').text('')
$('#imgsel').show()
localStorage.removeItem('image')
}
} catch { } catch {
var start = 'https://' + domain + '/api/v1/media' var start = 'https://' + domain + '/api/v1/media'
httpreq.open('POST', start, true) httpreq.open('POST', start, true)