backend-manager 2.3.4 → 2.3.7

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": "backend-manager",
3
- "version": "2.3.4",
3
+ "version": "2.3.7",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -55,10 +55,10 @@
55
55
  "semver": "^7.3.7",
56
56
  "shortid": "^2.2.16",
57
57
  "uid-generator": "^2.0.0",
58
- "ultimate-jekyll-poster": "^0.0.11",
58
+ "ultimate-jekyll-poster": "^0.0.13",
59
59
  "universal-analytics": "^0.5.3",
60
60
  "uuid": "^8.3.2",
61
- "wonderful-fetch": "^0.0.11",
61
+ "wonderful-fetch": "^0.0.13",
62
62
  "yargs": "^17.5.1"
63
63
  },
64
64
  "files": [
@@ -66,4 +66,4 @@
66
66
  "src/",
67
67
  "templates/"
68
68
  ]
69
- }
69
+ }
@@ -24,27 +24,37 @@ Module.prototype.main = function () {
24
24
  const poster = new Poster();
25
25
 
26
26
  // Save to disk OR commit
27
- poster.onDownload = async function (meta) {
27
+ poster.onDownload = function (meta) {
28
28
  return new Promise(async function(resolve, reject) {
29
- let finalPath = poster.removeDirDot(meta.finalPath);
30
- let tempPath = (meta.tempPath);
31
- await createFile(get(self.Manager.config, 'github.user'), repoInfo.user, repoInfo.name, get(self.Manager.config, 'github.key'), finalPath, await poster.readImage(tempPath))
32
- .catch((e) => {
33
- // console.log('---CAUGHT 1', e);
34
- })
35
- resolve();
29
+ const tempPath = (meta.tempPath);
30
+ const finalPath = poster.removeDirDot(meta.finalPath);
31
+
32
+ poster.readImage(tempPath)
33
+ .then(image => {
34
+ createFile(get(self.Manager.config, 'github.user'), repoInfo.user, repoInfo.name, get(self.Manager.config, 'github.key'), finalPath, image)
35
+ .then(() => {resolve()})
36
+ .catch((e) => {reject(e)})
37
+ })
38
+ .catch((e) => {reject(e)})
39
+
36
40
  });
37
41
  }
38
42
 
39
- const finalPost = await poster.create(payload.data);
43
+ const finalPost = await poster.create(payload.data).catch(e => e);
44
+
45
+ if (finalPost instanceof Error) {
46
+ return reject(assistant.errorManager(`Failed to post: ${finalPost}`, {code: 500, sentry: false, send: false, log: false}).error)
47
+ }
40
48
 
41
49
  // Save post OR commit
42
50
  await createFile(get(self.Manager.config, 'github.user'), repoInfo.user, repoInfo.name, get(self.Manager.config, 'github.key'), poster.removeDirDot(finalPost.path), finalPost.content)
51
+ .then(() => {
52
+ return resolve({data: finalPost});
53
+ })
43
54
  .catch((e) => {
44
55
  return reject(assistant.errorManager(`Failed to post: ${e}`, {code: 500, sentry: false, send: false, log: false}).error)
45
56
  })
46
57
 
47
- return resolve({data: finalPost});
48
58
  });
49
59
 
50
60
  };
@@ -106,26 +106,26 @@ Module.prototype.main = function () {
106
106
 
107
107
  }
108
108
 
109
-
110
109
  // Send notification
111
- const sentNotification = fetch(`https://us-central1-${Manager.project.projectId}.cloudfunctions.net/bm_api`, {
112
- method: 'POST',
113
- response: 'json',
114
- body: {
115
- authenticationToken: Manager.config.backend_manager.key,
116
- command: `admin:send-notification`,
117
- payload: {
118
- title: payload.data.payload.title,
119
- body: `"${payload.data.payload.title}" was just published on our blog. It's a great read and we think you'll enjoy the content!`,
120
- // click_action: `${Manager.config.brand.url}/${postUrl}`,
121
- click_action: `${Manager.config.brand.url}/blog`,
122
- icon: Manager.config.brand.brandmark,
123
- }
124
- },
125
- })
126
- .then(response => response)
127
- .catch(e => e);
128
-
110
+ if (payload.data.payload.sendNotification !== false) {
111
+ const sentNotification = fetch(`https://us-central1-${Manager.project.projectId}.cloudfunctions.net/bm_api`, {
112
+ method: 'POST',
113
+ response: 'json',
114
+ body: {
115
+ authenticationToken: Manager.config.backend_manager.key,
116
+ command: `admin:send-notification`,
117
+ payload: {
118
+ title: payload.data.payload.title,
119
+ body: `"${payload.data.payload.title}" was just published on our blog. It's a great read and we think you'll enjoy the content!`,
120
+ // click_action: `${Manager.config.brand.url}/${postUrl}`,
121
+ click_action: `${Manager.config.brand.url}/blog`,
122
+ icon: Manager.config.brand.brandmark,
123
+ }
124
+ },
125
+ })
126
+ .then(response => response)
127
+ .catch(e => e);
128
+ }
129
129
 
130
130
  return resolve({data: payload.response.data})
131
131