@@ -1087,7 +1087,7 @@ class WebhookHandler < Goliath::API
puts "RESPONSE9: #{msg.inspect}"
end
- done = Array(jparams['media']).map { |media_url|
+ media_urls = Array(jparams['media']).filter_map { |media_url|
unless media_url.end_with?(
'.smil', '.txt', '.xml'
)
@@ -1097,29 +1097,31 @@ class WebhookHandler < Goliath::API
bare_jid, media_url,
nil, nil, msg
)
+ media_url
end
-
- media_url
- }.empty?.then { |no_media|
- next if no_media
- next unless text&.empty?
- next unless jparams['to'].length > 1
-
- MessageEvent::In.new(
- timestamp: jparams['time'],
- from: jparams['from'],
- to: jparams['to'],
- owner: jparams['owner'],
- bandwidth_id: jparams['id'],
- body: jparams['text'].to_s,
- media_urls: media_urls
- ).emit(REDIS)
-
-
- next [200, {}, "OK"]
}
- return done unless done.nil?
+ if text&.empty? || (media_urls.any? && jparams['to'].length > 1)
+ if !env['HTTP_X_JMP_RESEND_OF'].to_s.empty?
+ MessageEvent::ResendIn.new(
+ original_stream_id: env['HTTP_X_JMP_RESEND_OF'],
+ original_bandwidth_id: jparams['id'],
+ owner: jparams['owner']
+ ).emit(REDIS)
+ else
+ MessageEvent::In.new(
+ timestamp: jparams['time'],
+ from: jparams['from'],
+ to: jparams['to'],
+ owner: jparams['owner'],
+ bandwidth_id: jparams['id'],
+ body: jparams['text'].to_s,
+ media_urls: media_urls
+ ).emit(REDIS)
+ end
+
+ return [200, {}, "OK"]
+ end
else
text = "unknown type (#{type})"\
" with text: " + jparams['text']