Merge pull request 'Support images embedded in keys' (#33) from embedded_img into dev

Reviewed-on: https://codeberg.org/keyoxide/web/pulls/33
This commit is contained in:
Yarmo Mackenbach 2020-08-20 15:47:17 +02:00
commit e9d2e4f927
2 changed files with 14 additions and 1 deletions

View file

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Add environment variable to set Onion-Location header
- Support images embedded in keys
### Fixed
- Fix env template DOMAIN name
- Fix non-updating guide titles

View file

@ -248,9 +248,17 @@ async function displayProfile(opts) {
let userName = userData.name ? userData.name : userData.email;
let userMail = userData.email ? userData.email : null;
let imgUri = null;
keyData.publicKey.users.forEach((user, i) => {
});
let notations = [], notationsRaw = [];
for (var i = 0; i < keyData.publicKey.users.length; i++) {
notationsRaw = notationsRaw.concat(keyData.publicKey.users[i].selfCertifications[0].notations);
if (keyData.publicKey.users[i].userAttribute != null && keyData.publicKey.users[i].userAttribute.attributes[0][0] === String.fromCharCode(1)) {
imgUri = "data:image/jpeg;base64," + btoa(keyData.publicKey.users[i].userAttribute.attributes[0].substring(17));
}
}
notationsRaw.forEach((item, i) => {
if (item[0] == "proof@metacode.biz") {
@ -305,7 +313,11 @@ async function displayProfile(opts) {
document.body.querySelector('#profileName').innerHTML = userName;
document.body.querySelector('#profileAvatar').style = "";
const profileHash = openpgp.util.str_to_hex(openpgp.util.Uint8Array_to_str(await openpgp.crypto.hash.md5(openpgp.util.str_to_Uint8Array(userData.email))));
document.body.querySelector('#profileAvatar').src = `https://www.gravatar.com/avatar/${profileHash}?s=128&d=mm`;
if (imgUri) {
document.body.querySelector('#profileAvatar').src = imgUri;
} else {
document.body.querySelector('#profileAvatar').src = `https://www.gravatar.com/avatar/${profileHash}?s=128&d=mm`;
}
document.title = `${userName} - Keyoxide`;
// Generate feedback