'use strict';

exports.main = async (event, context) => {
	let data = JSON.parse(event.body)
	const uniPush = uniCloud.getPushManager({ appId: data.appId })
	if (data.type == 'bindCid') {
		return await uniPush.cidBindAlias(data.alias);
	} else {
		return await uniPush.sendMessage({
			"getui_alias": data.toUser,
			"title": data.title,
			"content": data.content,
			"force_notification": data.force_notification ? data.force_notification : false,
			"payload": data.payload
		})
	}
}