Skip to content

Commit

Permalink
🔀 Merge pull request #283 from nwingt/develop
Browse files Browse the repository at this point in the history
Update for avatar upload & fix breaking change on noise-js
  • Loading branch information
nwingt authored Apr 28, 2022
2 parents 431a91b + 9491c5f commit f8b0429
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 51 deletions.
95 changes: 48 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@google-cloud/pubsub": "^1.2.0",
"@likecoin/iscn-js": "0.0.7",
"@likecoin/likecoin-email-templates": "^1.2.2",
"@likecoin/secretd-js": "^0.2.0",
"@likecoin/secretd-js": "^0.4.3",
"@sendgrid/mail": "^6.5.5",
"agentkeepalive": "^4.1.3",
"arweave": "^1.10.17",
Expand Down
2 changes: 1 addition & 1 deletion src/routes/users/registerLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ router.post(
}

await dbRef.doc(user).update({ avatar: avatarUrl });
res.sendStatus(200);
res.json({ avatar: avatarUrl });

const oldUserObj = await dbRef.doc(user).get();
const {
Expand Down
5 changes: 4 additions & 1 deletion src/util/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { ValidationError } from './ValidationError';
const sharp = require('sharp');
const fileType = require('file-type');
const sha256 = require('js-sha256');
// eslint-disable-next-line import/no-extraneous-dependencies
const md5 = require('md5-hex');

export function uploadFileAndGetLink(file, { filename, mimetype }) {
const isStream = file && typeof file.pipe === 'function';
Expand Down Expand Up @@ -58,7 +60,8 @@ export async function handleAvatarUploadAndGetURL(user, file, avatarSHA256) {
filename: `likecoin_store_user_${user}_${IS_TESTNET ? 'test' : 'main'}`,
mimetype: file.mimetype,
});
return avatarUrl;
const versionHash = md5(file.buffer).substring(0, 7);
return `${avatarUrl}&${versionHash}`;
}

export async function handleAvatarLinkAndGetURL(user, url) {
Expand Down
5 changes: 4 additions & 1 deletion test/stub/util/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { ValidationError } from './ValidationError';
const sharp = require('sharp');
const fileType = require('file-type');
const sha256 = require('js-sha256');
// eslint-disable-next-line import/no-extraneous-dependencies
const md5 = require('md5-hex');

export function uploadFileAndGetLink() {
return 'fakeAvatarUrl';
Expand All @@ -32,7 +34,8 @@ export async function handleAvatarUploadAndGetURL(user, file, avatarSHA256) {
filename: `likecoin_store_user_${user}_${IS_TESTNET ? 'test' : 'main'}`,
mimetype: file.mimetype,
});
return avatarUrl;
const versionHash = md5(file.buffer).substring(0, 7);
return `${avatarUrl}&${versionHash}`;
}

export async function handleAvatarLinkAndGetURL(user, url) {
Expand Down

0 comments on commit f8b0429

Please sign in to comment.