<commit_before>import { Notification } from '../models';
import { IApplication, INotification } from '../interfaces';
import publishStreamingMessage from './publish-streaming-message';

export default function createNotification(
	app: IApplication,
	userId: string,
	type: string,
	content: any
): Promise<INotification> {
	'use strict';

	return new Promise<INotification>((resolve, reject) => {
		Notification.create({
			app: app !== null ? app.id : null,
			user: userId,
			type: type,
			content: content
		}, (createErr: any, createdNotification: INotification) => {
			if (createErr !== null) {
				reject(createErr);
			} else {
				resolve(createdNotification);
				publishStreamingMessage(`userStream:${userId}`, JSON.stringify({
					type: 'notification',
					value: createdNotification.toObject()
				}));
			}
		});
	});
}<commit_msg>Fix bug<commit_after>import { Notification } from '../models';
import { IApplication, INotification } from '../interfaces';
import publishStreamingMessage from './publish-streaming-message';

export default function createNotification(
	app: IApplication,
	userId: string,
	type: string,
	content: any
): Promise<INotification> {
	'use strict';

	return new Promise<INotification>((resolve, reject) => {
		Notification.create({
			app: app !== null ? app.id : null,
			user: userId,
			type: type,
			content: content
		}, (createErr: any, createdNotification: INotification) => {
			if (createErr !== null) {
				reject(createErr);
			} else {
				resolve(createdNotification);
				publishStreamingMessage(`user-stream:${userId}`, JSON.stringify({
					type: 'notification',
					value: createdNotification.toObject()
				}));
			}
		});
	});
}
{'fraction_non_alphanumeric': 0.1457227138643068, 'fraction_numerical': 0.0, 'mean_word_length': 4.316614420062696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '340481', 'n_tokens_mistral': 565, 'n_tokens_neox': 495, 'n_words': 121}