Code Duplication    Length = 15-16 lines in 2 locations

chat/tornadoapp.py 2 locations

@@ 645-660 (lines=16) @@
642
			self.sync_redis.hset(connection_id, self.id, WebRtcRedisStates.READY)
643
			channel_status = self.sync_redis.shgetall(connection_id)
644
			del channel_status[self.id]
645
			message = {
646
				VarNames.EVENT: Actions.ACCEPT_CALL,
647
				VarNames.USER_ID: self.user_id,
648
				VarNames.CONNECTION_ID: connection_id,
649
				VarNames.WEBRTC_OPPONENT_ID: self.id,
650
				VarNames.HANDLER_NAME: HandlerNames.WEBRTC_TRANSFER,
651
			}
652
			for key in channel_status:
653
				if channel_status[key] != WebRtcRedisStates.CLOSED:
654
					self.publish(message, key)
655
		else:
656
			raise ValidationError("Invalid channel status")
657
658
	def offer_webrtc_connection(self, in_message):
659
		room_id = in_message[VarNames.CHANNEL]
660
		content = in_message.get(VarNames.CONTENT)
661
		qued_id = in_message[VarNames.WEBRTC_QUED_ID]
662
		connection_id = id_generator(RedisPrefix.CONNECTION_ID_LENGTH)
663
		# use list because sets dont have 1st element which is offerer
@@ 556-570 (lines=15) @@
553
		if res_imgs:
554
			Image.objects.bulk_create(res_imgs)
555
		if fetched_messages:
556
			for m in fetched_messages:
557
				res_imgs.append(m)
558
559
	def close_file_connection(self, in_message):
560
		connection_id = in_message[VarNames.CONNECTION_ID]
561
		self_channel_status = self.sync_redis.shget(connection_id, self.id)
562
		if not self_channel_status:
563
			raise Exception("Access Denied")
564
		if self_channel_status != WebRtcRedisStates.CLOSED:
565
			sender_id = self.sync_redis.shget(WEBRTC_CONNECTION, connection_id)
566
			if sender_id == self.id:
567
				self.close_file_sender(connection_id)
568
			else:
569
				self.close_file_receiver(connection_id, in_message, sender_id)
570
			self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.CLOSED)
571
572
	def close_call_connection(self, in_message):
573
		connection_id = in_message[VarNames.CONNECTION_ID]