Code Duplication    Length = 18-19 lines in 2 locations

chat/tornadoapp.py 2 locations

@@ 625-643 (lines=19) @@
622
				VarNames.CONNECTION_ID: connection_id,
623
				VarNames.WEBRTC_OPPONENT_ID: self.id,
624
				VarNames.HANDLER_NAME: HandlerNames.PEER_CONNECTION,
625
			}, sender_ws_id)
626
		else:
627
			raise ValidationError("Invalid channel status")
628
629
	# todo if we shgetall and only then do async hset
630
	# todo we can catch an issue when 2 concurrent users accepted the call
631
	# todo but we didn't  send them ACCEPT_CALL as they both were in status 'offered'
632
	# def accept_call(self, in_message):
633
	# 	connection_id = in_message[VarNames.CONNECTION_ID]
634
	# 	channel_status = self.sync_redis.shgetall(connection_id)
635
	# 	if channel_status and channel_status[self.id] == WebRtcRedisStates.RESPONDED:
636
	# 		self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.READY)
637
	# 		for key in channel_status:  # del channel_status[self.id] not needed as self in responded
638
	# 			if channel_status[key] == WebRtcRedisStates.READY:
639
	# 				self.publish({
640
	# 					VarNames.EVENT: Actions.ACCEPT_CALL,
641
	# 					VarNames.CONNECTION_ID: connection_id,
642
	# 					VarNames.WEBRTC_OPPONENT_ID: self.id,
643
	# 					VarNames.HANDLER_NAME: HandlerNames.WEBRTC_TRANSFER,
644
	# 				}, key)
645
	# 	else:
646
	# 		raise ValidationError("Invalid channel status")
@@ 536-553 (lines=18) @@
533
534
	def parse_imgs(self, imgs, mess_id):
535
		res_imgs = []
536
		if imgs:
537
			fetch = False
538
			for k in imgs:
539
				b64 =imgs[k].get(VarNames.IMG_B64)
540
				if b64:
541
					img = extract_photo(imgs[k][VarNames.IMG_B64], imgs[k][VarNames.IMG_FILE_NAME])
542
					res_imgs.append(Image(message_id=mess_id, img=img, symbol=k))
543
				else:
544
					fetch = True
545
			fetched_messages = None
546
			if fetch:
547
				fetched_messages = Image.objects.filter(message_id=mess_id)
548
				len(fetched_messages)  # fetch
549
			if res_imgs:
550
				Image.objects.bulk_create(res_imgs)
551
			if fetched_messages:
552
				for m in fetched_messages:
553
					res_imgs.append(m)
554
		return res_imgs
555
556
	def close_file_connection(self, in_message):