Parse-Server-Mailgun : How to edit templates and have them pushed to server - heroku

This is an extension to my previous question:
Setup mailgun with parse-server on Heroku
When you run '$ npm install parse-server-mailgun' it installs a bunch of directories and files on my current directory. However when i edit any of these, specifically the email templates, or anything thing that isnt in the main root directory of my parse-server-example folder, they don't push to Heroku.
I assume, if this is the case that it must just be pushing the main config files located in the root dir and then pulling the rest from nom somewhere?
How to i push the entire directory and all its sub folder/files to my Heroku server? Or edit the email templates already on the server?
Sorry this is a bit f a stupid question probably.

You should not modify the templates from the package's folder. Instead, create your own templates in your project's directory, and then reference those when initializing ParseServer. Then simply add these new files to your git repository and they'll be available on the server.
For instance:
emailAdapter: {
module: 'parse-server-mailgun',
options: {
// The address that your emails come from
fromAddress: 'Hello <hello#example.com>',
// Your domain from mailgun.com
domain: config.Mailgun.domain,
// Your API key from mailgun.com
apiKey: config.Mailgun.api,
templates: {
verificationEmail: {
subject: 'Please verify your e-mail for Example.com',
pathPlainText: './email/emailVerification/index.txt',
pathHtml: './email/emailVerification/index.html',
callback: function (user) { return { firstName: user.get('firstName') }; }
// Now you can use {{firstName}} in your templates
}
}
}
}

Simple fix. Put them in the root directory of the build. They will automatically be committed tot he server

You can use this mail adapter is really easy to use and also you can use it to multi language mails.
Hope that can help you. 😁👌
A little example of how you can use it.
emailAdapter: {
module: 'parse-smtp-template',
options: {
...
template: true,
templatePath: "views/templates/template.html",
// Custome options to your emails
// You can add more options if you need
passwordOptions: {
subject: "Password recovery",
body: "Custome pasword recovery email body",
btn: "Recover your password"
/* --EXTRA PARAMETERS--
others: {
extraParameter
}
*/
},
confirmOptions: {
subject: "E-mail confirmation",
body: "Custome email confirmation body",
btn: "confirm your email"
},
}
}
https://github.com/macarthuror/parse-smtp-template

Related

Strapi : Email setting fields seems to be disabled mode. How to enabled this

I am using latest version of strapi (v4.0.0)
In Email settings ---> fields seems to be disabled
How to enable this fields
Well, those fields are readonlyand are only configurable via the plugins.js file. Create the following file:
// filepath - config/plugins.js
module.exports = ({ env }) => ({
// ...
email: {
config: {
provider: 'sendmail',
settings: {
defaultFrom: 'myemail#protonmail.com',
defaultReplyTo: 'myemail#protonmail.com',
},
},
},
// ...
});
Once done, just start the strapi server again using yarn develop command and you should see your values being reflected in the admin. Then you can even try sending out a test email using the Send Test Email button.
Reference:
Strapi Email Plugin

How do I implement a "Settings" section for a custom Teams Message Extension?

I built a small teams message extension which just uses some user input, builds a link from it, and returns a card with a button pointing to that link.
I need to add a Settings section, but I couldn't find proper instructions or a sample for this.
I tried to use this sample as example (which is JS, and I'm using TypeScript), but I could not get it to work.
Relevant portion in my class:
export class MessageExtensionBot extends TeamsActivityHandler {
...
protected handleTeamsMessagingExtensionConfigurationQuerySettingUrl(context: TurnContext, query: MessagingExtensionQuery): Promise<MessagingExtensionResponse> {
return Promise.resolve({
composeExtension: {
type: "config",
suggestedActions: {
actions: [
{
title: "Title",
type: ActionTypes.OpenUrl,
value: "https://" + `${process.env.PUBLIC_HOSTNAME}` + "/settings.html"
}
]
}
}
});
}
protected handleTeamsMessagingExtensionConfigurationSetting(context, settings): Promise<void> {
return Promise.resolve(undefined);
}
process.env.PUBLIC_HOSTNAME points to the temporary ngrok link, smth like xxx-yyy-zzz.ngrok.io.
When I access xxx-yyy-zzz.ngrok.io/settings.html, I get the correct content of that html file
I also added "canUpdateConfiguration": true, in my manifest file, and the Settings link is available.
THE PROBLEM: when I click the Settings link in my custom teams message extension, all I get is a pop-up with the error message Sorry, the setting of this compose extension is not available. Please try again later. and an OK button.
What is wrong/missing in my code ?
Thank you.
We also faced this issue. It is resolved after adding validDomains in the manifest. Please try updating the validDomains in manifest, hope this resolves the issue.

Parse Server Mail gun adapter installation

First off, I am running Parse Server on AWS Elastic Beanstalk.
I see this documentation in the readme file
##### Email verification and password reset
Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the `parse-server` package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
```js
var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: true,
// set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email
// set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified
preventLoginWithUnverifiedEmail: false, // defaults to false
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
// Set the mount path as it is in serverURL
publicServerURL: 'https://example.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
});
This doesn't say enough for me though. I am not using an existing express website and I need to know where in the repository to add the mailgun code.
I already have mailgun and have used it in php and I am using this explicitly to reset user passwords.
so again, What file in my parse server folder do I need to add the mailgun adapter?
This is my file structure. If I am being unclear, let me know...
This is where I am at now as far as adding it in. Is this right? My mailgun creds are not in there yet, but I know to do that.
class ParseServer {
constructor({
appId = requiredParameter('You must provide an appId!'),
masterKey = requiredParameter('You must provide a masterKey!'),
appName,
filesAdapter,
push,
loggerAdapter,
logsFolder,
databaseURI,
databaseOptions,
databaseAdapter,
cloud,
collectionPrefix = '',
clientKey,
javascriptKey,
dotNetKey,
restAPIKey,
webhookKey,
fileKey = undefined,
facebookAppIds = [],
enableAnonymousUsers = true,
allowClientClassCreation = true,
oauth = {},
serverURL = requiredParameter('You must provide a serverURL!'),
maxUploadSize = '20mb',
verifyUserEmails = true,
preventLoginWithUnverifiedEmail = false,
cacheAdapter,
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
},
publicServerURL,
customPages = {
invalidLink: undefined,
verifyEmailSuccess: undefined,
choosePassword: undefined,
passwordResetSuccess: undefined
},
parse-server include the mailgun-js module by default so you can use it without any dependency. What you need to do in order to use it is the following:
Create mailgun account and get an ApiKey from there
Include the mail gun simple adapter exactly like how it is included in the code that you provided and just change the values to the relevant values
please notice that the adapter that you add above is only for email verification and password reset. If you want the ability to send an email (e.g. marketing emails, engagement etc.) you can create a cloud code function there you will need to require the mailgun-js module and use the mailgun-js module to send the email exactly like how it is described in here
Then from your client code you will need to trigger this cloud code function and the email will be sent.

How do you configure an emailAdapter for parse-server?

I'm trying to test out the password reset flow on a locally running parse-server instance. Every time I send a password reset request I get the following error error: Uncaught internal server error. Trying to send a reset password but no adapter is set undefined. I know I'm supposed to configure the emailAdapter in cli-definitions but I'm not too sure what exactly I'm supposed to put there. I tried changing the contructor in ParseServer.js to have
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
but that did not work. Any help is greatly appreciated!
Just got this configured myself and I think you may just be missing a few parameters.
In the configuration in your index.js or other file where ParseServer is being initialized, you need all of the following:
verifyUserEmails: true,
// Same as the SERVER_URL used to configure ParseServer, in my case it uses Heroku
publicServerURL: 'http://MY_HEROKU_APP.herokuapp.com/parse',
appName: 'MY_APP',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'no-reply#example.com',
domain: 'example.com',
apiKey: 'key-XXXXXX',
}
}

How I can require script from data folder

I want to load js file from page and require it in background page.
I try use two copy in lib and in data folder, but have problem with review.
I can load it from lib folder in page, but it uncomfortable for other browsers.
I can load it via loader:
mono = require('toolkit/loader').main(require('toolkit/loader').Loader({
paths: {
'sdk/': 'resource://gre/modules/commonjs/sdk/',
'data/': self.data.url('js/'),
'': 'resource:///modules/'
},
name: self.name,
prefixURI: 'resource://'+self.id.slice(1, -1)+'/'
}), "data/mono");
But have problem with:
require('net/xhr').XMLHttpRequest
I try use for options it, but have same problems.
require('#loader/options')
Now I use it, but all require objects I send via arguments.
Have ideas?
upd
Now I use this code, it allow require modules and don't store it in memory, as I think. But need to declare all modules previously.
mono = require('toolkit/loader').main(require('toolkit/loader').Loader({
paths: {
'data/': self.data.url('js/')
},
name: self.name,
prefixURI: 'resource://'+self.id.slice(1, -1)+'/',
globals: {
console: console,
_require: function(path) {
switch (path) {
case 'sdk/timers':
return require('sdk/timers');
case 'sdk/simple-storage':
return require('sdk/simple-storage');
case 'sdk/window/utils':
return require('sdk/window/utils');
case 'sdk/self':
return require('sdk/self');
default:
console.log('Module not found!', path);
}
}
}
}), "data/mono");
I think this blogpost from erikvold addresses the problem you are facing: http://work.erikvold.com/jetpack/2014/09/23/jp-pro-tip-reusing-js.html

Resources