How to attach an ICS (calendar invite) to an email and have it automatically accepted and added to calendar? - email

It seems when you get an email from a confirmation of a flight booking or an Airbnb reservation, GMail automatically adds an event to your calendar that is already pre-approved. Wondering how that happens? I've looked at all the other answers like this one and was able to get the Calendar invite to show up on the email and Google Calendar but not to have it be automatically approved. This gist was also useful in getting to this point, but now I can't find any information. Even more confusing: if you look at the Flights/Airbnb reservation emails, you won't see any attachments to the emails (no .ics). This is what my event data for the ics library looks like:
const event = {
start: startDate,
end: endDate,
status: 'CONFIRMED',
busyStatus: 'FREE',
organizer: {
name: myName,
email: myEmail,
},
attendees: [
{
name,
email,
rsvp: true,
partstat: 'ACCEPTED',
},
],
url: calUrl,
title: calTitle,
summary: calSummary,
description: calDescription,
location: address,
productId: productId,
method: 'PUBLISH',
};

Related

How to send confirmation order to an email provided through a post request

I have an ecommerce website (no user authentication) which stores some products (localStorage) and creates a post request with the user's mail provided in the form, along with the list of products.
The api path is www.api.site.com/api/orders. I am wondering how to send the order summary to the user's email, provided in the post request it sent.
Here is my Cart.js
var products = JSON.parse(localStorage.getItem("products"));
const onSubmit = (data) => { //on send order button press
var object = {
list: products, //the products list
...data, //email and phone
};
axios
.post(`https://api.*site*.com/api/orders`, {
data: {
email: object.email,
phone: object.phone,
items: object.list,
},
}).then(...)
I have seen that in every documentation, the controllers send the same mail to the same address
example :
// path: ./src/api/{api name}/controllers/{api name}.js or ./src/api/{api name}/services/{api name}.js
await strapi.plugins['email'].services.email.send({
to: 'valid email address',
from: 'your verified email address', //e.g. single sender verification in SendGrid
...
}),
How can I pass the user's email to the 'from' field? Any suggestion would be much appreciated.

How to setup Paypal subscriptions with multiple currencies?

For each product we do the following:
When a new product is added, create a new Product with POST /v1/catalogs/products
Using the product_id from step 1, create a new plan POST /v1/billing/plans
Whenever a customer clicks "Subscribe" button, we create a new subscription using plan_id from step 2 with POST /v1/billing/subscriptions
Problem: When creating the subscription we are able to change the price the customer will be billed by passing the plan object to POST /v1/billing/subscriptions endpoint to override the amount of the plan. However passing in a different currency throws an error:
"The currency code is different from the plan's currency code."
With that being said, is thereĀ a way to setup paypal subscriptions where we can pass in a different currency? Is it required to create a new plan for each currency because this does not seem like a good solution
We create a billing plan with the following body:
{
product_id: productId,
name: planName,
status: 'ACTIVE',
billing_cycles: [
{
frequency: {
interval_unit: 'MONTH',
interval_count: 1
},
tenure_type: 'REGULAR',
sequence: 1,
// Create a temporary pricing_scheme. This will be replaced
// with a variable amount when a subscription is created.
pricing_scheme: {
fixed_price: {
value: '1',
currency_code: 'CAD'
}
},
total_cycles: 0
}
],
payment_preferences: {
auto_bill_outstanding: true,
payment_failure_threshold: 2
}
}
We create subscription with the following body (however passing in a different currency than the plan (CAD) throws an error):
{
plan_id: planId,
subscriber: {
email_address: email
},
plan: {
billing_cycles: [
{
sequence: 1,
pricing_scheme: {
fixed_price: {
value: amount,
currency_code: currency
}
}
}
]
},
custom_id: productId
};
Is it required to create a new plan for each currency
Yes

YouTrack email notification using custom fields

I've added a custom field for 'interested parties' (users) in a particular issue, not project specific, and it works fine.
I would like YouTrack to generate emails to their email address on update or change of the issue, like they do to the person who it is assigned to, is this possible?
Let's say you want to send notifications by e-mail when a ticket is ready to be reviewed. People responsible for the review are set via a Reviewer custom field (which can contain multiple values). Then you can send notifications as follows:
var entities = require('#jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.stateMachine({
title: 'Workflow',
fieldName: 'State',
states: {
'To Be Reviewed': {
onEnter: function(ctx) {
var issue = ctx.issue;
issue.fields.Reviewer.forEach(function(user) {
user.notify("Reminder", "This is a reminder", true);
});
},
transitions: {}
},
},
requirements: {
Reviewer: {
type: entities.User.fieldType,
multi: true
}
}
});
You can create a custom workflow like the following one:
when {
if (Interested Parties.isNotEmpty) {
for each user in Interested Parties {
user.notify("subj", "body");
}
}
}
Another point is that you probably do not need this field since you can 'star' an issue on behalf of a user and the user thus will be notified about any changes. Just type star user_name in the command window.

Saving a Dgrid JsonRest-based Store

I have a dgrid that has editable date fields. Above it, I have a "Save" button that calls grid.save. When I hit the button, it makes an XHR request back to the store's target, but does not provide any data back to the server for me to save (i.e. POST is empty). Right now it is hardwired to query item id 1900, as you can see in the code below.
Here is how the store is initiated:
var store = new JsonRest({
target: "/safari/resources/1900/calendarObjects/",
sortParam: "sort",
idProperty: "id",
properties: {
startDate:{
format: "date-time"
},
endDate:{
format: "date-time"
}
}
});
And here is the grid:
var grid = new declare([OnDemandGrid, dgridEditor, Keyboard, Selection, DijitRegistry])({
store: store,
query: {responseType: "json" },
bufferRows: 40,
loadingMessage: "Loading...",
columns: [
{field: "oid", label: "Object ID"},
dgridEditor({field: "startDate", name: "Start Date", editorArgs: { selector: 'date', datePattern: 'yyyy-MM-dd', locale: 'en-us' }}, DateTextBox),
dgridEditor({field: "startTime", name: "Start Time"}, TimeTextBox, "click"),
dgridEditor({field: "endDate", name: "End Date"}, DateTextBox, "click"),
dgridEditor({field: "endTime", name: "End Time"}, TimeTextBox, "click"),
{field: "endDateOid", label: "End OID"}
],
}, "grid");
The save button looks like this:
registry.byId("saveButton").on("click", function (){
grid.save();
});
Like I said, after I click "save," a new XHR request fires, but if it is sending any data back to the server, I'm not sure where it is going. I had my backend print up all of the HTTP headers it received and didn't see anything.
UPDATE (January 2, 2013): Upgraded server backend to use a traditional RESTful URL, which seems to make Dojo slightly happier, but it still is using GET instead of PUT and fails to actually send anything to save.
UPDATE (January 5, 2013): Is there any reason why JsonRest would call GET before calling PUT? I'm wondering if my program needs to return certain data before the program is willing to go do the PUT (and thus the problem isn't the GET but whatever comes next)... But, this is entirely speculation. I've reached a dead end.
I'm not sure whether this will work, you can have a look at https://github.com/SitePen/dgrid/blob/master/test/JsonRest.html
window.grid = new (declare([Grid, Selection, Keyboard]))({
store: testStore,
getBeforePut: false,
columns: columns
}, "grid");
and you can try to set the property getBeforePut to false.

Facebook Messenger Chatbot how do I collect the users geo location that they send?

In Facebook Messenger there is an icon allowing the user to send their geo coordinates.
Is this available on the Facebook Messenger platform yet i.e. if a user sends me their location does my Chatbot have access to it? If so how is it done because i can't see it in the response in my webhook.
You get the location as attachment in message. See sample below:
{ mid: 'mid.1463464074086:96b149e1a047e47842',
seq: 2076,
attachments:
[ { title: 'Anupam\'s Location',
url: 'https://www.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%2Fdefault.aspx%3Fv%3D2%26pc%3DFACEBK%26mid%3D8100%26where1%3D19.120002%252C%2B72.863715%26FORM%3DFBKPL1%26mkt%3Den-US&h=AAQH523sr&s=1&enc=AZNmEBjv3zHHm0_dYnEIC6j7EDsJNt8PZRZZyaXbIZ6VzjPsQUOOaMIPGtXFH17CevUiNK0_K594CgDQHAMQSru7uS_jjbkxojBWNwBnncqzaw',
type: 'location',
payload: [Object] } ] }
From the payload, you can access the Latitude and Longitude using:
lat = event.message.attachments[0].payload.coordinates.lat
lng = event.message.attachments[0].payload.coordinates.long
Yes, the location will be sent as an attachment in the message. If you are referring to the example code given in the facebook messenger platform documentation the fix can be done as follows....(please refer the complete code here https://developers.facebook.com/docs/messenger-platform/quickstart)
in the else section
else if (messageAttachments) {
console.log(messageAttachments[0].payload.coordinates.lat); //gives you lat
console.log(messageAttachments[0].payload.coordinates.long); // gives you long
}
There is a bug for now about getting some of users' location.
When my users share their location in facebook-messenger-bot;
While I can get the location of users like below response;
{ mid: 'mid.1463464074086:96b149e1a047e47842',
seq: 2076,
attachments:
[ { title: 'Fatih\'s Location',
url: 'https://www.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%..',
type: 'location',
payload: [Object]
} ] }
But can't get the location of some other users like below response;
{
{ mid: 'mid.$cAAD53Ka90kBmfY23q1gTEdy6rrmW', seq: 19104}
}
Facebook Team still working on this bug, this is the link if you want to browse:
https://developers.facebook.com/bugs/160926314660178/