@social-mail/social-mail-web-server 1.4.747 → 1.4.749

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": "@social-mail/social-mail-web-server",
3
- "version": "1.4.747",
3
+ "version": "1.4.749",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -262,8 +262,8 @@ export default class AppFileEvents extends AuthenticatedEvents<AppFile> {
262
262
  if (entry.isModified("parentID")) {
263
263
  if (entity.parentID && entity.path) {
264
264
  const pf = await this.db.appFiles.where(entity, (p) => (x) => x.appFileID === p.appFileID).first();
265
- if (pf.path.startsWith(entity.path)) {
266
- throw new EntityAccessError(`Circular path detected`);
265
+ if (pf.path !== entity.path && pf.path.startsWith(entity.path)) {
266
+ throw new EntityAccessError(`Circular path detected ${pf.path} starts with ${entity.path}`);
267
267
  }
268
268
  }
269
269
  }
@@ -20,7 +20,7 @@ export default class ImageConverterService {
20
20
  @Inject
21
21
  tempFileService: TempFileService;
22
22
 
23
- async getImage(file: LocalFile) {
23
+ async getImage(file: LocalFile, pageNumber?) {
24
24
 
25
25
  let outputFile: LocalFile;
26
26
  let folder: TempFolder;
@@ -55,12 +55,18 @@ export default class ImageConverterService {
55
55
  }
56
56
 
57
57
  if(/pdf/i.test(file.contentType)) {
58
- await spawnPromise("pdftoppm", [
58
+
59
+ const args = [
59
60
  "-singlefile",
60
61
  "-png",
61
62
  copy.path,
62
63
  "png"
63
- ], {
64
+ ];
65
+ if (pageNumber) {
66
+ args.push("-f");
67
+ args.push(Number(pageNumber).toString());
68
+ }
69
+ await spawnPromise("pdftoppm", args, {
64
70
  cwd: folder.folder
65
71
  });
66
72
 
@@ -82,8 +88,6 @@ export default class ImageConverterService {
82
88
 
83
89
  async transform(type, file: LocalFile, outputFileName = "file.jpg") {
84
90
 
85
- file = await this.getImage(file);
86
-
87
91
  let { ext } = parse(outputFileName);
88
92
  let fileName = type;
89
93
  const matches = type.match(/(\w+)\(([^\)]+)\)/);
@@ -115,6 +119,8 @@ export default class ImageConverterService {
115
119
  }
116
120
  }
117
121
 
122
+ file = await this.getImage(file, args?.[2] ?? void 0);
123
+
118
124
  const { default: fx } = await import("./formats/" + fileName + ".js");
119
125
  let r: sharp.Sharp = await fx(file, ... args);
120
126