Fixed issue #880 - No chat message over 5000 chars possible. E. g. if image is pasted.

This commit is contained in:
Martin Edenhofer 2017-04-20 13:15:40 +02:00
parent de7fef8c18
commit e26aa1f599
5 changed files with 38 additions and 11 deletions

View file

@ -474,9 +474,10 @@ class ChatWindow extends App.Controller
event.data.callback()
@$('.js-customerChatInput').ce({
mode: 'richtext'
multiline: true
maxlength: 40000
mode: 'richtext'
multiline: true
maxlength: 40000
imageWidth: 'relative'
})
disconnect: =>

View file

@ -6,6 +6,7 @@
# maxlength: 123
# multiline: true / disable enter + strip on paste
# placeholder: 'some placeholder'
# imageWidth: absolute (<img style="width: XXpx; height: XXXpx" src="">) || relative (<img style="width: 100%; max-width: XXpx;" src="">)
*/
var pluginName = 'ce',
@ -13,6 +14,7 @@
debug: false,
mode: 'richtext',
multiline: true,
imageWidth: 'absolute',
allowKey: {
8: true, // backspace
9: true, // tab
@ -284,7 +286,12 @@
}
_this.log('image inserted')
result = dataUrl
img = "<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">"
if (_this.options.imageWidth == 'absolute') {
img = "<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">"
}
else {
img = "<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">"
}
document.execCommand('insertHTML', false, img)
}
@ -399,7 +406,12 @@
//console.log('dataUrl', dataUrl)
_this.log('image inserted')
result = dataUrl
img = $("<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">")
if (_this.options.imageWidth == 'absolute') {
img = $("<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">")
}
else {
img = $("<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">")
}
img = img.get(0)
if (document.caretPositionFromPoint) {

View file

@ -434,7 +434,7 @@ class CreateTicket < ActiveRecord::Migration
create_table :chat_messages do |t|
t.integer :chat_session_id, null: false
t.string :content, limit: 5000, null: false
t.text :content, limit: 20.megabytes + 1, null: false
t.integer :created_by_id, null: true
t.timestamps limit: 3, null: false
end

View file

@ -0,0 +1,10 @@
class ChatIncreaseMessageSize < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
change_column :chat_messages, :content, :text, limit: 20.megabytes + 1, null: false
end
end

View file

@ -7,13 +7,17 @@ class Sessions::Event
begin
backend = load_adapter(adapter)
rescue => e
return { error: "No such event #{params[:event]}" }
return { event: 'error', data: { error: "No such event #{params[:event]}", payload: params[:payload] } }
end
instance = backend.new(params)
result = instance.run
instance.destroy
result
begin
instance = backend.new(params)
result = instance.run
instance.destroy
result
rescue => e
return { event: 'error', data: { error: e.message, payload: params[:payload] } }
end
end
end