Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crosspost discussion items to nostr #522

Merged
merged 16 commits into from
Oct 4, 2023

Conversation

AustinKelsay
Copy link
Contributor

@AustinKelsay AustinKelsay commented Sep 26, 2023

Crosspostr

This PR implements crossposting of discussion items from stacker.news to nostr as nip-23 long-form parameterized replaceable events.

High level summary:

  • crosspost discussion items to nostr
  • requires NIP-07 extension for signing
  • we use your NIP-05 relays if set
  • otherwise we default to these relays:
    • wss://nostrue.com/
    • wss://relay.damus.io/
    • wss://relay.nostr.band/
    • wss://relay.snort.social/
    • wss://nostr21.com/

User facing changes:

  • User can check the nostr crossposting checkbox on their settings to enable automatic attempted crossposting on all of their discussion items
  • User can check the nostr crossposting checkbox under advanced for a one-off crossposting of a discussion item
    • If the user already has nostr crossposting checked on their settings they can uncheck it under advanced to NOT crosspost a particular discussion item.
  • User gets an info modal for each of these checkboxes explaining the feature
  • While the user is crossposting they get a success toast for each relay that there event was successfully published to
  • Any failed relays get grouped up in a danger toast and shown to the user giving them the option to recursively retry until all failed relays succeed or skip the failed relays and finish the post
  • If the user edits a post within the edit window they will re-crosspost it if crossposting is enabled. Since these events are parameterized and replaceable, when they are edited and republished the relays will discard the old version of the event and only keep the latest version.
  • The nostr nip-05 section that was hidden under an accordion is now simply shown as the 'nostr' section and it is not hidden by default

Internal code changes:

  • Added migration for nostrCrossposting boolean
  • Added crosspostDiscussion function in lib/nostr
  • Added generic publishNostrEvent function in lib/nostr
  • Added functionality to toast component to optionally allow triggering removal of the toast from the component that invokes it
  • Added functionality to toast component to trigger an optional callback when the toast is closed
  • Added crosspost handler function in discussion-form
  • Added relayError function in discussion-form

@SatsAllDay
Copy link
Contributor

Really nice PR description, I need to get better about that!

lib/nostr.js Outdated Show resolved Hide resolved
@huumn huumn merged commit b3aee50 into stackernews:master Oct 4, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants