profile: support kind 0 metadata events #37

Merged
offbyn merged 1 commits from profile-settings into master 2 years ago
offbyn commented 2 years ago
Owner

Added simple profile form to the setting view to send kind 0
metdata such as: name, about and picture.

Part of #9

Added simple profile form to the setting view to send kind 0 metdata such as: name, about and picture. Part of https://git.qcode.ch/nostr/nostrweb/issues/9
offbyn added 1 commit 2 years ago
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
662de1b2b6
profile: support kind 0 metadata events
This is a rudimentary prototype to send kind 0 metdata such as,
name, about and picture. Does not work currently, submitting the
form errors with a notice 'could not parse command'.
offbyn self-assigned this 2 years ago
offbyn commented 2 years ago
Poster
Owner

I am getting a "error" Notice, when submitting this form with 'could not parse command', but not sure what exactly triggers this. also for some reason could not catch the error text.

I am getting a "error" Notice, when submitting this form with 'could not parse command', but not sure what exactly triggers this. also for some reason could not catch the error text.
x1ddos reviewed 2 years ago
src/main.js Outdated
@ -6,2 +6,2 @@
pool.addRelay('wss://relay.nostr.info', {read: true, write: true});
pool.addRelay('wss://relay.damus.io', {read: true, write: true});
// pool.addRelay('wss://relay.nostr.info', {read: true, write: true});
// pool.addRelay('wss://relay.damus.io', {read: true, write: true});
x1ddos commented 2 years ago
Owner

please undo 🙏 otherwise my feed will be quite empty :)

please undo 🙏 otherwise my feed will be quite empty :)
offbyn commented 2 years ago
Poster
Owner

will do, sorry, this is just for debugging.

I opened this PR to ask for help as I got stuck. added draft

will do, sorry, this is just for debugging. I opened this PR to ask for help as I got stuck. added draft
offbyn marked this conversation as resolved
src/main.js Outdated
@ -663,0 +695,4 @@
};
const sig = await signEvent(newProfile, privatekey).catch(console.error);
if (sig) {
const ev = await pool.publish({...newProfile, sig}, (status, url) => {
x1ddos commented 2 years ago
Owner

huh. i can't find publish method. did they replace it with send? f85fb82b8d

huh. i can't find `publish` method. did they replace it with `send`? https://github.com/jb55/nostr-js/commit/f85fb82b8dae12c176f390375c740929e34a9665
offbyn commented 2 years ago
Poster
Owner
wrong repo :) https://github.com/fiatjaf/nostr-tools/blob/1b798b2eeef376eddcac85ebbf83c24a06538600/pool.js#L170
offbyn marked this conversation as resolved
offbyn changed title from profile: support kind 0 metadata events to draft: profile: support kind 0 metadata events 2 years ago
x1ddos commented 2 years ago
Owner

strange, the notice error. let me check if there's any logs on relay.x1ddos.

strange, the notice error. let me check if there's any logs on relay.x1ddos.
x1ddos commented 2 years ago
Owner

ok, so the relay says parse error:

data did not match any variant of untagged enum NostrMessage

not sure yet what that means... going to look at NostrMessage in nostr-rs-relay.

ok, so the relay says parse error: > data did not match any variant of untagged enum NostrMessage not sure yet what that means... going to look at `NostrMessage` in nostr-rs-relay.
x1ddos commented 2 years ago
Owner

@offbyn i found the issue. turns out, nostr-rs-relay always expects the tags field, even if empty. so, this works:

diff --git src/main.js src/main.js
index 926db4b..4880f9d 100644
--- src/main.js
+++ src/main.js
@@ -689,6 +689,7 @@ profileForm.addEventListener('submit', async (e) => {
 
   const newProfile = {
     kind: 0,
+    tags: [],
     pubkey,
     content: JSON.stringify(Object.fromEntries(form)),
     created_at: Math.floor(Date.now() * 0.001),
@offbyn i found the issue. turns out, nostr-rs-relay always expects the `tags` field, even if empty. so, this works: ```patch diff --git src/main.js src/main.js index 926db4b..4880f9d 100644 --- src/main.js +++ src/main.js @@ -689,6 +689,7 @@ profileForm.addEventListener('submit', async (e) => { const newProfile = { kind: 0, + tags: [], pubkey, content: JSON.stringify(Object.fromEntries(form)), created_at: Math.floor(Date.now() * 0.001), ```
offbyn force-pushed profile-settings from 662de1b2b6 to 0290eac31f 2 years ago
offbyn commented 2 years ago
Poster
Owner

nostr-rs-relay always expects the tags field, even if empty.

omg thank you so much.

> nostr-rs-relay always expects the tags field, even if empty. omg thank you so much.
offbyn changed title from draft: profile: support kind 0 metadata events to profile: support kind 0 metadata events 2 years ago
offbyn force-pushed profile-settings from 0290eac31f to 476bb8add6 2 years ago
offbyn requested review from x1ddos 2 years ago
offbyn commented 2 years ago
Poster
Owner

PTAL

PTAL
x1ddos approved these changes 2 years ago
x1ddos left a comment
Owner

lgtm

lgtm
src/index.html Outdated
@ -61,1 +61,4 @@
</div> -->
<form action="#" name="profile" autocomplete="new-password">
<label for="name">name</label>
<input type="text" name="name" id="name" autocomplete="off" pattern="[a-zA-Z_0-9][a-zA-Z_\-0-9]+[a-zA-Z_0-9]">
x1ddos commented 2 years ago
Owner

would set the id to something more specific. name is such a broad id. maybe profile_name? same for about and picture.

would set the `id` to something more specific. `name` is such a broad id. maybe `profile_name`? same for about and picture.
offbyn commented 2 years ago
Poster
Owner

👍 done

👍 done
offbyn force-pushed profile-settings from 476bb8add6 to dd1076489f 2 years ago
offbyn force-pushed profile-settings from dd1076489f to e2431c7e60 2 years ago
offbyn merged commit e2431c7e60 into master 2 years ago
offbyn deleted branch profile-settings 2 years ago

Reviewers

x1ddos approved these changes 2 years ago
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
The pull request has been merged as e2431c7e60.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b profile-settings master
git pull origin profile-settings

Step 2:

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff profile-settings
git push origin master
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: nostr/nostrweb#37
Loading…
There is no content yet.