Browse code

FIX: ukladanie sprav pod spravym autorom

Cinan Rakosnik authored on 29/05/2013 at 18:56:01
Showing 1 changed files
... ...
@@ -132,7 +132,7 @@ class WsChatController < WsController
132 132
             stripped_to = Jabber::JID.new(message[:to]).strip!.to_s
133 133
             if can_save_conversation?(stripped_me, stripped_to, chat_id)
134 134
                 Rails.logger.debug ['saving sent message', stripped_me]
135
-                save_encrypted_message(message[:message], stripped_me, stripped_to, chat_id)
135
+                save_encrypted_message(message[:message], stripped_me, stripped_me, stripped_to, chat_id)
136 136
             end
137 137
 
138 138
             trigger_success message[:message]
... ...
@@ -261,7 +261,7 @@ class WsChatController < WsController
261 261
 
262 262
         if can_save_conversation?(stripped_me, stripped_from, chat_id)
263 263
             Rails.logger.debug ['saving received message', stripped_me, chat_id]
264
-            save_encrypted_message(body, stripped_me, stripped_from, chat_id)
264
+            save_encrypted_message(body, stripped_me, stripped_from, stripped_from, chat_id)
265 265
         end
266 266
 
267 267
         send_message 'app.chat.messageReceived',
... ...
@@ -304,11 +304,11 @@ class WsChatController < WsController
304 304
         end
305 305
     end
306 306
 
307
-    def save_encrypted_message(message, stripped_me, stripped_to, chat_id)
307
+    def save_encrypted_message(message, stripped_me, stripped_from, stripped_with, chat_id)
308 308
         credentials = User.crendentials_for_token(session[:token])
309 309
         found_account = credentials.detect do |c| c['jid'] == stripped_me end
310 310
         user_pass = Security::decrypt(found_account['pass'], connection_store[:cipher_key], connection_store[:cipher_iv])
311 311
         encrypted_msg = Security::encrypt(message, user_pass, Rails.application.config.aes_iv)
312
-        History.save_message(stripped_me, stripped_me, encrypted_msg, stripped_to, chat_id)
312
+        History.save_message(stripped_me, stripped_from, encrypted_msg, stripped_with, chat_id)
313 313
     end
314 314
 end
315 315
\ No newline at end of file