Jelajahi Sumber

Bugfix, Avatar upload message "avatar-too-big" shows now the configured max filesize

Martin Filser 2 tahun lalu
induk
melakukan
7de50c0f4b
3 mengubah file dengan 6 tambahan dan 3 penghapusan
  1. 1 1
      imports/i18n/data/de.i18n.json
  2. 1 1
      imports/i18n/data/en.i18n.json
  3. 4 1
      models/avatars.js

+ 1 - 1
imports/i18n/data/de.i18n.json

@@ -134,7 +134,7 @@
     "attachmentDeletePopup-title": "Anhang löschen?",
     "attachments": "Anhänge",
     "auto-watch": "Neue Boards nach Erstellung automatisch beobachten",
-    "avatar-too-big": "Das Profilbild ist zu groß (520KB max)",
+    "avatar-too-big": "Das Profilbild ist zu groß (__size__ max)",
     "back": "Zurück",
     "board-change-color": "Farbe ändern",
     "show-at-all-boards-page": "Zeige auf \"Alle Boards\" Seite",

+ 1 - 1
imports/i18n/data/en.i18n.json

@@ -134,7 +134,7 @@
   "attachmentDeletePopup-title": "Delete Attachment?",
   "attachments": "Attachments",
   "auto-watch": "Automatically watch boards when they are created",
-  "avatar-too-big": "The avatar is too large (520KB max)",
+  "avatar-too-big": "The avatar is too large (__size__ max)",
   "back": "Back",
   "board-change-color": "Change color",
   "show-at-all-boards-page" : "Show at All Boards page",

+ 4 - 1
models/avatars.js

@@ -3,10 +3,13 @@ import { FilesCollection } from 'meteor/ostrio:files';
 import { formatFleURL } from 'meteor/ostrio:files/lib';
 import { isFileValid } from './fileValidation';
 import { createBucket } from './lib/grid/createBucket';
+import { TAPi18n } from '/imports/i18n';
 import fs from 'fs';
 import path from 'path';
 import FileStoreStrategyFactory, { FileStoreStrategyFilesystem, FileStoreStrategyGridFs, STORAGE_NAME_FILESYSTEM } from '/models/lib/fileStoreStrategy';
 
+const filesize = require('filesize');
+
 let avatarsUploadExternalProgram;
 let avatarsUploadMimeTypes = [];
 let avatarsUploadSize = 72000;
@@ -84,7 +87,7 @@ Avatars = new FilesCollection({
     if (file.size <= avatarsUploadSize && file.type.startsWith('image/')) {
       return true;
     }
-    return 'avatar-too-big';
+    return TAPi18n.__('avatar-too-big', {size: filesize(avatarsUploadSize)});
   },
   onAfterUpload(fileObj) {
     // current storage is the filesystem, update object and database