Code Duplication    Length = 12-15 lines in 2 locations

chat/tornado/message_handler.py 2 locations

@@ 361-375 (lines=15) @@
358
		self.publish(message, room_id, True)
359
360
	def edit_message(self, data):
361
		js_id = data[VarNames.JS_MESSAGE_ID]
362
		message = do_db(Message.objects.get, id=data[VarNames.MESSAGE_ID])
363
		validate_edit_message(self.user_id, message)
364
		message.content = data[VarNames.CONTENT]
365
		MessageHistory(message=message, content=message.content, giphy=message.giphy).save()
366
		message.edited_times += 1
367
		giphy_match = self.isGiphy(data[VarNames.CONTENT])
368
		if message.content is None:
369
			Message.objects.filter(id=data[VarNames.MESSAGE_ID]).update(deleted=True, edited_times=message.edited_times)
370
			self.publish(self.create_send_message(message, Actions.DELETE_MESSAGE, None, js_id), message.room_id)
371
		elif giphy_match is not None:
372
			self.edit_message_giphy(giphy_match, message, js_id)
373
		else:
374
			self.edit_message_edit(data, message, js_id)
375
376
	def edit_message_giphy(self, giphy_match, message, js_id):
377
		def edit_glyphy(message, giphy):
378
			do_db(Message.objects.filter(id=message.id).update, content=message.content, symbol=message.symbol, giphy=giphy,
@@ 459-470 (lines=12) @@
456
	def offer_webrtc_connection(self, in_message):
457
		room_id = in_message[VarNames.CHANNEL]
458
		content = in_message.get(VarNames.CONTENT)
459
		qued_id = in_message[VarNames.WEBRTC_QUED_ID]
460
		connection_id = id_generator(RedisPrefix.CONNECTION_ID_LENGTH)
461
		# use list because sets dont have 1st element which is offerer
462
		self.async_redis_publisher.hset(WEBRTC_CONNECTION, connection_id, self.id)
463
		self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.READY)
464
		opponents_message = self.offer_webrtc(content, connection_id, room_id, in_message[VarNames.EVENT])
465
		self_message = self.set_connection_id(qued_id, connection_id)
466
		self.ws_write(self_message)
467
		self.logger.info('!! Offering a webrtc, connection_id %s', connection_id)
468
		self.publish(opponents_message, room_id, True)
469
470
	def retry_file_connection(self, in_message):
471
		connection_id = in_message[VarNames.CONNECTION_ID]
472
		opponent_ws_id = in_message[VarNames.WEBRTC_OPPONENT_ID]
473
		sender_ws_id = self.sync_redis.shget(WEBRTC_CONNECTION, connection_id)