通过Firebase功能生成日历邀请

时间:2017-10-27 07:54:45

标签: javascript node.js firebase calendar google-cloud-functions

我正在使用 Firebase ,正在寻找一种方法来生成某个触发器上的iCal / vcs文件。我一直在调查ics.js,但我不确定这是否可行。

背景

因此,用户使用应用创建了一个事件,这会被发送到Firebase,这会触发一个事件(触发器已经存在),其中日历邀请是通过 nodemailer

这甚至可能吗?

1 个答案:

答案 0 :(得分:1)

创建邮件传输

const mailTransport = nodemailer.createTransport({
service: 'gmail',
auth: {
    user: gmailEmail,
    pass: gmailPassword,
 },
});

创建校准事件

// Create ical object
let cal = ical();

const event = cal.createEvent({
    start: event_start,
    summary: event_name,
    end: new Date(event_start.getTime() + 3600000),
    location: address
});

event.organizer({
    name: author_name,
    email: author_email,
    mailto: author_email
});

// Update event description
event.description(email_text);

// Set up mail options
const mailOptions = {
                    from: `"Your corp." <${gmailEmail}`,
                    to: user_email,
                    subject: `Here is your event"`,
                    text: email_text,
                    icalEvent: {
                        method: 'request',
                        content: new Buffer(cal.toString())
                    }
                    };



// Send mailOptions
mailTransport.sendMail(mailOptions).then(() => console.log(`Invite sent`
                                   .catch((error) => console.error('There was an error while sending the email:', error));