<commit_before>/*
 * Command to handle eventPush from APS
 */
Ape.registerCmd("eventpush", false, function(params, info) {
	if(params.to && params.data){
		
		if(params.multi){
			var recipient = Ape.getChannelByPubid(params.pipe);
		}else{
			var recipient = Ape.getUserByPubid(params.pipe);
		}
		
		if(!!!recipient) return ["425", "UNKNOWN_RECIPIENT"];
		
		//User Source From
		var user = Ape.getUserByPubid(params.from);
		if (typeof user.pipe == "undefined" && params.sessid != user.prop("sessid"))
			return ["424", "UNKNOWN_SENDER"];
		
		//Send Data to the Reccipient
		recipient.sendEvent(params.data, {"from": user.pipe});
		
		if(!!params.sync){
			var sync = params.data;
			sync.chanid = params.to;
			user.pipe.sendRaw("SYNC", sync);
		}
		
		return {"name":"PUSHED","data":{"value":"ok"}};
	}else{
		return 0;
	}
});<commit_msg>Updated eventpush command to return error 425 in case of unkown recipient<commit_after>/*
 * Command to handle eventPush from APS
 */
Ape.registerCmd("eventpush", false, function(params, info) {
	if(params.to && params.data){
		
		var recipient = Ape.getChannelByPubid(params.to);
		
		//Try if the recipient is an user
		if(!recipient)
			recipient = Ape.getUserByPubid(params.to);
		
		if(recipient){
			//User Source From
			var user = Ape.getUserByPubid(params.from);
			if (typeof user.pipe == "undefined" && params.sessid != user.prop("sessid"))
				return ["424", "UNKNOWN_SENDER"];
			
			//Send Data to the Reccipient
			recipient.sendEvent(params.data, {"from": user.pipe});
			
			Ape.log("");	//IMPORTANT: if this line comented a segfault error crashes the server			
			if(params.sync){
				var sync = params.data;
				sync.chanid = params.to;
				user.pipe.sendRaw("SYNC", sync);
			}
			
			return {"name":"PUSHED","data":{"value":"ok"}};
		}
		
		return ["425", "UNKNOWN_RECIPIENT"];
	}else{
		return 0;
	}
});
{'fraction_non_alphanumeric': 0.1647940074906367, 'fraction_numerical': 0.00909577314071696, 'mean_word_length': 3.675, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '667185', 'n_tokens_mistral': 765, 'n_tokens_neox': 644, 'n_words': 150}