Code Duplication    Length = 12-15 lines in 2 locations

chat/tornado/message_handler.py 2 locations

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