Code Duplication    Length = 12-15 lines in 2 locations

chat/tornado/message_handler.py 2 locations

@@ 361-375 (lines=15) @@
358
		validate_edit_message(self.user_id, message)
359
		message.content = data[VarNames.CONTENT]
360
		MessageHistory(message=message, content=message.content, giphy=message.giphy).save()
361
		message.edited_times += 1
362
		selector = Message.objects.filter(id=message_id)
363
		giphy_match = self.isGiphy(data[VarNames.CONTENT])
364
		if message.content is None:
365
			action = Actions.DELETE_MESSAGE
366
			prep_files = None
367
			selector.update(deleted=True, edited_times=message.edited_times)
368
		elif giphy_match is not None:
369
			def edit_glyphy(message, giphy):
370
				do_db(selector.update, content=message.content, symbol=message.symbol, giphy=giphy, edited_times=message.edited_times)
371
				message.giphy = giphy
372
				self.publish(self.create_send_message(message, Actions.EDIT_MESSAGE, None, js_id), message.room_id)
373
			self.search_giphy(message, giphy_match, edit_glyphy)
374
			return
375
		else:
376
			action = Actions.EDIT_MESSAGE
377
			message.giphy = None
378
			files = UploadedFile.objects.filter(id__in=data.get(VarNames.FILES), user_id=self.user_id)
@@ 459-470 (lines=12) @@
456
		sender_ws_id = self.sync_redis.shget(WEBRTC_CONNECTION, connection_id)
457
		receiver_ws_status = self.sync_redis.shget(connection_id, opponent_ws_id)
458
		if receiver_ws_status == WebRtcRedisStates.READY and self.id == sender_ws_id:
459
			self.publish(self.retry_file(connection_id), opponent_ws_id)
460
		else:
461
			raise ValidationError("Invalid channel status.")
462
463
	def reply_file_connection(self, in_message):
464
		connection_id = in_message[VarNames.CONNECTION_ID]
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 and self_ws_status == WebRtcRedisStates.OFFERED:
469
			self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.RESPONDED)
470
			self.publish(self.reply_webrtc(
471
				Actions.REPLY_FILE_CONNECTION,
472
				connection_id,
473
				HandlerNames.WEBRTC_TRANSFER,