Code Duplication    Length = 12-15 lines in 2 locations

chat/tornado/message_handler.py 2 locations

@@ 361-375 (lines=15) @@
358
		else:
359
			raise ValidationError("Invalid channel status.")
360
361
	def reply_file_connection(self, in_message):
362
		connection_id = in_message[VarNames.CONNECTION_ID]
363
		sender_ws_id = self.sync_redis.shget(WEBRTC_CONNECTION, connection_id)
364
		sender_ws_status = self.sync_redis.shget(connection_id, sender_ws_id)
365
		self_ws_status = self.sync_redis.shget(connection_id, self.id)
366
		if sender_ws_status == WebRtcRedisStates.READY and self_ws_status == WebRtcRedisStates.OFFERED:
367
			self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.RESPONDED)
368
			self.publish(self.reply_webrtc(
369
				Actions.REPLY_FILE_CONNECTION,
370
				connection_id,
371
				HandlerNames.WEBRTC_TRANSFER,
372
				in_message[VarNames.CONTENT]
373
			), sender_ws_id)
374
		else:
375
			raise ValidationError("Invalid channel status.")
376
377
	def reply_call_connection(self, in_message):
378
		self.send_call_answer(
@@ 459-470 (lines=12) @@
456
				continue
457
			self.publish(message, ws_id)
458
459
	def accept_file(self, in_message):
460
		connection_id = in_message[VarNames.CONNECTION_ID]
461
		content = in_message[VarNames.CONTENT]
462
		sender_ws_id = self.sync_redis.shget(WEBRTC_CONNECTION, connection_id)
463
		sender_ws_status = self.sync_redis.shget(connection_id, sender_ws_id)
464
		self_ws_status = self.sync_redis.shget(connection_id, self.id)
465
		if sender_ws_status == WebRtcRedisStates.READY \
466
				and self_ws_status in [WebRtcRedisStates.RESPONDED, WebRtcRedisStates.READY]:
467
			self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.READY)
468
			self.publish(self.get_accept_file_message(connection_id, content), sender_ws_id)
469
		else:
470
			raise ValidationError("Invalid channel status")
471
472
	# todo
473
	# we can use channel_status = self.sync_redis.shgetall(connection_id)