fix: robohash image missing with NIP05 login
This commit is contained in:
parent
1f0faef6f6
commit
b2a419adbf
@ -37,20 +37,44 @@ export class AuthController {
|
|||||||
* or error if otherwise
|
* or error if otherwise
|
||||||
*/
|
*/
|
||||||
async authAndGetMetadataAndRelaysMap(pubkey: string) {
|
async authAndGetMetadataAndRelaysMap(pubkey: string) {
|
||||||
this.metadataController
|
|
||||||
.findMetadata(pubkey)
|
|
||||||
.then((event) => {
|
|
||||||
store.dispatch(setMetadataEvent(event))
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.warn('Error occurred while finding metadata', err)
|
|
||||||
|
|
||||||
const emptyMetadata = this.metadataController.getEmptyMetadataEvent()
|
const emptyMetadata = this.metadataController.getEmptyMetadataEvent()
|
||||||
|
|
||||||
emptyMetadata.content = JSON.stringify({
|
emptyMetadata.content = JSON.stringify({
|
||||||
picture: getRoboHashPicture(pubkey)
|
picture: getRoboHashPicture(pubkey)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.metadataController
|
||||||
|
.findMetadata(pubkey)
|
||||||
|
.then((event) => {
|
||||||
|
if (event) {
|
||||||
|
// In case of NIP05 there is scenario where login content will be populated but without an image
|
||||||
|
// In such case we will add robohash image
|
||||||
|
if (event.content) {
|
||||||
|
const content = JSON.parse(event.content)
|
||||||
|
|
||||||
|
if (!content) {
|
||||||
|
event.content = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!content.picture) {
|
||||||
|
content.picture = getRoboHashPicture(pubkey)
|
||||||
|
}
|
||||||
|
|
||||||
|
event.content = JSON.stringify(content)
|
||||||
|
} else {
|
||||||
|
event.content = JSON.stringify({
|
||||||
|
picture: getRoboHashPicture(pubkey)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
store.dispatch(setMetadataEvent(event))
|
||||||
|
} else {
|
||||||
|
store.dispatch(setMetadataEvent(emptyMetadata))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn('Error occurred while finding metadata', err)
|
||||||
|
|
||||||
store.dispatch(setMetadataEvent(emptyMetadata))
|
store.dispatch(setMetadataEvent(emptyMetadata))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user