mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-21 21:30:08 +00:00
Send the tmpHash instead of the attachmentId
All the PHP goodies reside inside the AttachmentHandler which expects the tmpHash.
This commit is contained in:
parent
9a870f3f94
commit
5fce0c092c
@ -334,7 +334,7 @@ define([ './Chat/console'
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onSendAttachment(event) {
|
async onSendAttachment(event) {
|
||||||
return this.bottle.container.Messenger.pushAttachment(event.detail.attachmentId)
|
return this.bottle.container.Messenger.pushAttachment(event.detail.tmpHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
onAutocomplete(event) {
|
onAutocomplete(event) {
|
||||||
|
@ -56,9 +56,9 @@ define([ './console'
|
|||||||
return Ajax.api(this, payload)
|
return Ajax.api(this, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushAttachment(attachmentId) {
|
async pushAttachment(tmpHash) {
|
||||||
const payload = { actionName: 'pushAttachment'
|
const payload = { actionName: 'pushAttachment'
|
||||||
, parameters: { attachmentId }
|
, parameters: { tmpHash }
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ajax.api(this, payload)
|
return Ajax.api(this, payload)
|
||||||
|
@ -39,6 +39,7 @@ define([ 'WoltLabSuite/Core/Language'
|
|||||||
|
|
||||||
this.room = room
|
this.room = room
|
||||||
this.previewContainer = previewContainer
|
this.previewContainer = previewContainer
|
||||||
|
this.tmpHash = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
@ -82,10 +83,10 @@ define([ 'WoltLabSuite/Core/Language'
|
|||||||
elShow(this.uploadDescription)
|
elShow(this.uploadDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
async send(attachmentId, event) {
|
async send(tmpHash, event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const parameters = { promise: Promise.resolve()
|
const parameters = { promise: Promise.resolve()
|
||||||
, attachmentId
|
, tmpHash
|
||||||
}
|
}
|
||||||
this.emit('send', parameters)
|
this.emit('send', parameters)
|
||||||
|
|
||||||
@ -99,14 +100,14 @@ define([ 'WoltLabSuite/Core/Language'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createButtonGroup(uploadId, objectID) {
|
createButtonGroup(uploadId, objectId, tmpHash) {
|
||||||
const buttonGroup = document.createElement('ul')
|
const buttonGroup = document.createElement('ul')
|
||||||
buttonGroup.classList.add('buttonGroup')
|
buttonGroup.classList.add('buttonGroup')
|
||||||
|
|
||||||
let li = document.createElement('li')
|
let li = document.createElement('li')
|
||||||
const cancelButton = document.createElement('span')
|
const cancelButton = document.createElement('span')
|
||||||
cancelButton.classList.add('button', 'jsDeleteButton')
|
cancelButton.classList.add('button', 'jsDeleteButton')
|
||||||
cancelButton.dataset.objectId = objectID
|
cancelButton.dataset.objectId = objectId
|
||||||
cancelButton.dataset.eventName = 'attachment'
|
cancelButton.dataset.eventName = 'attachment'
|
||||||
cancelButton.innerText = Language.get('wcf.global.button.cancel')
|
cancelButton.innerText = Language.get('wcf.global.button.cancel')
|
||||||
li.appendChild(cancelButton)
|
li.appendChild(cancelButton)
|
||||||
@ -115,9 +116,8 @@ define([ 'WoltLabSuite/Core/Language'
|
|||||||
li = document.createElement('li')
|
li = document.createElement('li')
|
||||||
const sendButton = document.createElement('span')
|
const sendButton = document.createElement('span')
|
||||||
sendButton.classList.add('button')
|
sendButton.classList.add('button')
|
||||||
sendButton.dataset.objectId = objectID
|
|
||||||
sendButton.innerText = Language.get('wcf.global.button.submit')
|
sendButton.innerText = Language.get('wcf.global.button.submit')
|
||||||
sendButton.addEventListener('click', (e) => this.send(objectID, e))
|
sendButton.addEventListener('click', (e) => this.send(tmpHash, e))
|
||||||
li.appendChild(sendButton)
|
li.appendChild(sendButton)
|
||||||
buttonGroup.appendChild(li)
|
buttonGroup.appendChild(li)
|
||||||
|
|
||||||
@ -131,13 +131,13 @@ define([ 'WoltLabSuite/Core/Language'
|
|||||||
* @see WoltLabSuite/Core/Upload#_getParameters
|
* @see WoltLabSuite/Core/Upload#_getParameters
|
||||||
*/
|
*/
|
||||||
_getParameters() {
|
_getParameters() {
|
||||||
const hash = [ ...crypto.getRandomValues(new Uint8Array(20)) ]
|
this.tmpHash = [ ...crypto.getRandomValues(new Uint8Array(20)) ]
|
||||||
.map(m => ('0' + m.toString(16)).slice(-2))
|
.map(m => ('0' + m.toString(16)).slice(-2))
|
||||||
.join('')
|
.join('')
|
||||||
|
|
||||||
return { objectType: "be.bastelstu.chat.message"
|
return { objectType: "be.bastelstu.chat.message"
|
||||||
, parentObjectID: this.room.roomID
|
, parentObjectID: this.room.roomID
|
||||||
, tmpHash: hash
|
, tmpHash: this.tmpHash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ define([ 'WoltLabSuite/Core/Language'
|
|||||||
|
|
||||||
DomUtil.replaceElement(progress, img)
|
DomUtil.replaceElement(progress, img)
|
||||||
|
|
||||||
this.createButtonGroup(uploadId, attachment.attachmentID)
|
this.createButtonGroup(uploadId, attachment.attachmentID, this.tmpHash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user