@webbio/strapi-plugin-page-builder 0.12.7-platform → 0.12.8-platform

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.12.7-platform",
3
+ "version": "0.12.8-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -36,23 +36,32 @@ export default async ({ strapi }: { strapi: Strapi }) => {
36
36
  models: [USER_PERMISSION_USER_PLUGIN],
37
37
  async beforeUpdate(event) {
38
38
  if (event.params.data.id) {
39
- const userToUpdate = await strapi.entityService?.findOne(USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
40
- populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
41
- });
42
- if (userToUpdate) {
43
- if (event.params.data.activateUser && event.params.data.confirmed && !userToUpdate.confirmMailSend) {
44
- await strapi.service(PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
45
- // @ts-ignore strapi typings
46
- from: userToUpdate.platform.platformEmails.accountAcceptedMail.fromEmail,
47
- to: event.params.data.email,
48
- // @ts-ignore
49
- subject: userToUpdate.platform.platformEmails.accountAcceptedMail.subject,
50
- // @ts-ignore
51
- text: userToUpdate.platform.platformEmails.accountAcceptedMail.message,
52
- firstName: event.params.data.firstName,
53
- lastName: event.params.data.lastName
54
- });
39
+ const originalUserObject = await strapi.entityService?.findOne(
40
+ USER_PERMISSION_USER_PLUGIN,
41
+ event.params.data.id,
42
+ {
43
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
55
44
  }
45
+ );
46
+
47
+ if (
48
+ originalUserObject &&
49
+ event.params.data.activateUser &&
50
+ event.params.data.confirmed &&
51
+ !originalUserObject.confirmMailSend
52
+ ) {
53
+ await strapi.service(PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
54
+ // @ts-ignore strapi typings
55
+ from: originalUserObject.platform.platformEmails.accountAcceptedMail.fromEmail,
56
+ to: event.params.data.email,
57
+ // @ts-ignore
58
+ subject: originalUserObject.platform.platformEmails.accountAcceptedMail.subject,
59
+ // @ts-ignore
60
+ text: originalUserObject.platform.platformEmails.accountAcceptedMail.message,
61
+ firstName: event.params.data.firstName,
62
+ lastName: event.params.data.lastName
63
+ });
64
+ event.params.data.confirmMailSend = true;
56
65
  }
57
66
  }
58
67
  }
@@ -1,6 +1,7 @@
1
1
  import * as AWS from '@aws-sdk/client-ses';
2
2
  import { txtEmail } from './private-content/mail-template/txtMail.email.template.text';
3
3
  import { USER_PERMISSION_USER_PLUGIN } from '../../shared/utils/constants';
4
+ import { errors } from '@strapi/utils';
4
5
 
5
6
  interface SendOptions {
6
7
  from: string;
@@ -32,6 +33,7 @@ export default {
32
33
  });
33
34
  } catch (error) {
34
35
  console.error(error);
36
+ throw new errors.ApplicationError('Failed to send email', error);
35
37
  }
36
38
  },
37
39
  async sendAdminMail(user) {