Skip to content

Commit

Permalink
Add both links
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Apr 3, 2024
1 parent c224203 commit 9df5a2b
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/lib/nostr.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,22 @@ const connectedPromise = ndk.connect();
export const REPORT_KIND = 1984;

export default class Nostr {
static async maybeFetchNip05(reportRequest) {
const user = ndk.getUser({ hexpubkey: reportRequest.reporterPubkey });
static async updateNjump(reportRequest, hexpubkey, fieldToUpdate) {
const user = ndk.getUser({ hexpubkey });
const profile = await user.fetchProfile();

if (profile?.nip05) {
const njump = `https://njump.me/${profile.nip05}`;
reportRequest.njump = njump;
return;
reportRequest[fieldToUpdate] = njump;
}
}

const reportedUser = ndk.getUser({
hexpubkey: reportRequest.reportedEvent.pubkey,
});
const reportedUserProfile = await reportedUser.fetchProfile();

if (reportedUserProfile?.nip05) {
const njump = `https://njump.me/${reportedUserProfile.nip05}`;
reportRequest.reportedUserNjump = njump;
return;
}
static async maybeFetchNip05(reportRequest) {
await updateNjump(reportRequest, reportRequest.reporterPubkey, "njump");
await updateNjump(
reportRequest,
reportRequest.reportedEvent.pubkey,
"reportedUserNjump"
);
}

// Creates a NIP-32 event flagging a Nostr event.
Expand Down

0 comments on commit 9df5a2b

Please sign in to comment.