<commit_before>import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
import Message from '../../../../../models/messaging-message';
import { isValidText } from '../../../../../models/messaging-message';
import History from '../../../../../models/messaging-history';
import User, { ILocalUser } from '../../../../../models/user';
import Mute from '../../../../../models/mute';
import DriveFile from '../../../../../models/drive-file';
import { pack } from '../../../../../models/messaging-message';
import { publishUserStream } from '../../../../../stream';
import { publishMessagingStream, publishMessagingIndexStream } from '../../../../../stream';
import pushSw from '../../../../../push-sw';
import config from '../../../../../config';

export const meta = {
	desc: {
		ja: '指定したユーザーへMessagingのメッセージを送信します。',
		en: 'Create a message of messaging.'
	},

	requireCredential: true,

	kind: 'messaging-write'
};

export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
	// Get 'userId' parameter
	const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
	if (recipientIdErr) return rej('invalid userId param');

	// Myself
	if (recipientId.equals(user._id)) {
		return rej('cannot send message to myself');
	}
<commit_msg>Clean up<commit_after>import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
import Message from '../../../../../models/messaging-message';
import { isValidText } from '../../../../../models/messaging-message';
import History from '../../../../../models/messaging-history';
import User, { ILocalUser } from '../../../../../models/user';
import Mute from '../../../../../models/mute';
import DriveFile from '../../../../../models/drive-file';
import { pack } from '../../../../../models/messaging-message';
import { publishUserStream } from '../../../../../stream';
import { publishMessagingStream, publishMessagingIndexStream } from '../../../../../stream';
import pushSw from '../../../../../push-sw';

export const meta = {
	desc: {
		ja: '指定したユーザーへMessagingのメッセージを送信します。',
		en: 'Create a message of messaging.'
	},

	requireCredential: true,

	kind: 'messaging-write'
};

export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
	// Get 'userId' parameter
	const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
	if (recipientIdErr) return rej('invalid userId param');

	// Myself
	if (recipientId.equals(user._id)) {
		return rej('cannot send message to myself');
	}

{'fraction_non_alphanumeric': 0.2534986005597761, 'fraction_numerical': 0.0, 'mean_word_length': 2.6419213973799125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3397325', 'n_tokens_mistral': 793, 'n_tokens_neox': 779, 'n_words': 199}