Skip to content

Conversation

@akhileshthite
Copy link
Collaborator

@akhileshthite akhileshthite commented Oct 3, 2024

Distributed Press Organizing (view)
hyphacoop/distributed-press-organizing#194

distributed-press-cli/
├── bin/
│   └── dp-cli.js
├── src/
│   ├── commands/
│   │   ├── cloneSite.js
│   │   ├── createSite.js
│   │   ├── generateKeypair.js
│   │   ├── pathSite.js
│   │   ├── publishSite.js
│   │   ├── registerActor.js
│   │   ├── registerPublisher.js
│   │   ├── sendPost.js
│   │   └── setAuthToken.js
│   ├── config/
│   │   └── config.js
│   └── api/
│       ├── dpApi.js
│       └── socialInboxApi.js
├── .gitignore
├── package.json
├── README.md
└── defaults.json

@akhileshthite akhileshthite added the enhancement New feature or request label Oct 3, 2024
@akhileshthite akhileshthite self-assigned this Oct 3, 2024
Copy link
Contributor

@RangerMauve RangerMauve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the structure so far. Before merging lets make sure the APIs being called are correct.

Copy link
Contributor

@RangerMauve RangerMauve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should have the following:

dp-cli publish ./folder_here and dp-cli patch ./folder_here for taking a folder or maybe a glob pattern, turning the data into a tarball, and publishing the new site content.

Also, we should have a way to create a trial account and a dp-cli clone to trigger a wget site clone via the new APIs

README.md Outdated

### Send a Post to Followers

Publish a post to your followers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this publish a message to the DP site and register it in the outbox? Or ist it sending out an activity without an ID? Should test whether messages sent like this are actually visible on mastodon. We should explain how this works.

return
}

const activityId = `${config.socialInboxUrl}/${encodeURIComponent(actorUsername)}/outbox/${uuidv4()}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of generating a new activity we should have users pass a path to the activity that's published in the site via the DP API.

Alternately we should save both the Activity and Note to the DP published site as well as update the outbox. This would bring the functionality closer to the jekyll plugin.

@akhileshthite
Copy link
Collaborator Author

Getting SSL mismatch error for cloning the site:

dp-cli clone dp.akhilesh.art

Cloning site with ID: dp.akhilesh.art
Error cloning site: Status: 500, Message: Internal Server Error
Response Data: {
  "statusCode": 500,
  "code": "5",
  "error": "Internal Server Error",
  "message": "Command failed: wget2   --random-wait   --compression=identity,gzip,br   --user-agent=\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0\"   --local-encoding=UTF-8   --mirror   --page-requisites   --convert-links   --adjust-extension   --continue   --no-host-directories   --directory-prefix=dp.akhilesh.art   \"https://dp.akhilesh.art\"\nERROR: The certificate is NOT trusted. The name in the certificate does not match the expected. \n"
}
Hint: It appears that the server is unable to clone your site due to an SSL certificate trust issue. Please ensure your domain has a valid, trusted SSL certificate that matches your domain name.

Copy link
Contributor

@RangerMauve RangerMauve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Lets add all these docs to docs.distributed.press as well. Make a new section called SDK and have separate pages for the CLI and the template

console.log(chalk.blue(`Downloading site content from ${siteUrl} to ${outputDirectory}...`))

// Dynamically load `website-scraper`
const { default: scrape } = await loadWebsiteScraper()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be doing a scrape/download, that's what the clone HTTP API does already. IT's enough to trigger the clone and just output the site URLs

Copy link
Collaborator Author

@akhileshthite akhileshthite Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hyphacoop/api.distributed.press#94

365efb3

dp-cli clone ranger.mauve.moe

Cloning site with ID: ranger.mauve.moe
Server-side cloning initiated successfully!
Cloned Site Info:
{
  "id": "ranger.mauve.moe",
  "domain": "ranger.mauve.moe",
  "protocols": {
    "http": true,
    "hyper": true,
    "ipfs": true
  },
  "links": {
    "http": {
      "enabled": true,
      "link": "https://ranger.mauve.moe"
    },
    "hyper": {
      "gateway": "https://ranger-mauve-moe.hyper.hypha.coop/",
      "raw": "hyper://xxsog44z58458te7gkxgrggmxwastm94om6d9n1hjsjtsi7rt9wo/",
      "dnslink": "/hyper/xxsog44z58458te7gkxgrggmxwastm94om6d9n1hjsjtsi7rt9wo/",
      "enabled": true,
      "link": "hyper://ranger.mauve.moe"
    },
    "ipfs": {
      "gateway": "https://ranger-mauve-moe.ipns.ipfs.hypha.coop",
      "cid": "bafybeibwjxk563q3lw226qdlptwzvjk7skyfsbblqa4jc4ulhuftcevqsi",
      "pubKey": "ipns://k51qzi5uqu5dkyebpkw5k4kkecddn0bnd9zch18g9bpb4htoulp439uyb4gugc/",
      "dnslink": "/ipns/k51qzi5uqu5dkyebpkw5k4kkecddn0bnd9zch18g9bpb4htoulp439uyb4gugc/",
      "enabled": true,
      "link": "ipns://ranger.mauve.moe/"
    }
  },
  "public": true
}

@akhileshthite
Copy link
Collaborator Author

e116f29
dp-cli register-actor

Registering your actor with the Social Inbox...
? Enter your actor username (e.g., @username@domain.com): @dp@staticpub.distributed.press
? Enter your actor URL: https://staticpub.distributed.press/about.jsonld
? Enter your public key ID (e.g., https://domain.com/actor#main-key): https://staticpub.distributed.press/about.jsonld#main-key
Actor registered with Social Inbox successfully!
Response: {
  "actorUrl": "https://staticpub.distributed.press/about.jsonld",
  "publicKeyId": "https://staticpub.distributed.press/about.jsonld#main-key",
  "keypair": {
    "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtZSfTeCr1Wv5NO9inU2O\nk7yI+PHdBrpKrrsxQTXPfz1vWq6myObDKT+SKpxy86LBoY8Ow5/DfEW07vSQpeyq\nYS6PhNzRTKFLe64YhQVMG9CFFnKt804pMe+DcGm4XZsPfaBWgPOkSw14vgLCusvE\nMSa19+uUu4hW1zhFuHPfS2/HacANT3gXo9Qd3nyGd1Pap7zba9bBBbp2/V7ZJloC\nLPO/2fvB0B9bcYebFN7AWsOnDDMwus2LKo5eTqiWAy8C9AissPzo9zGPseOhvBxP\nz7MRJVOON5FZexFjv5b6UjUEqHBT+6Qb8H3WUo3RIrmfbX6rsLWJW5Lm+TJyV9kk\nF0k/5nFIfYa5+DxbzvEFTRvaUEoxK2H4I+jA3an8sTb7uHCWQ5LeYzMEOwosfoL8\ngtEuqQ47K+0fazPS87EfGYv7IAariDsV/9wQyPKODebkfsdJtdc9lyJT9a5uncqt\nTg9V30Z9rcwbRcA/YhRa45ZqB8N7Py6BBcHW/tpQ/AJeDc0UNoZn9rJBN3Lz3OTg\n14aBwLme9ctaZ2MJR7o9np4qMJYBIyUP173eBOtUjXYENWmsfs2kt5lSGAbSSdRf\nAdJmi2Hsbbk54T5BgkBsYZEDIUOPu9o/jxFKCW31nOIx1Kgi9b4i/hC3S/9PYx1T\nWILtVslgUpWj+CXmhYES2mUCAwEAAQ==\n-----END PUBLIC KEY-----\n",
    "privateKeyPem": "-----BEGIN PRIVATE KEY-----\nBLAH-BLAH\n-----END PRIVATE KEY-----\n"
  },
  "announce": false,
  "manuallyApprovesFollowers": false
}

@akhileshthite
Copy link
Collaborator Author

akhileshthite commented Dec 3, 2024

6f2fdea

Getting 500 for dp-cli send-post ./posts/helloworld.jsonld
https://github.com/hyphacoop/staticpub.distributed.press/blob/initial/posts/helloworld.jsonld

https://github.com/RangerMauve/staticpub.mauve.moe/blob/default/helloworld.jsonld

Sending a post to followers...
Sending to URL: https://social.distributed.press/v1/%40dp%40staticpub.distributed.press/outbox
Activity Payload: {
  "@context": "https://www.w3.org/ns/activitystreams",
  "id": "https://staticpub.distributed.press/posts/helloworld.jsonld",
  "url": "https://staticpub.distributed.press/helloworld",
  "type": "Note",
  "summary": null,
  "published": "2023-06-29T17:29:45Z",
  "attributedTo": "https://staticpub.distributed.press/about.jsonld",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "cc": [],
  "sensitive": false,
  "atomUri": "https://staticpub.distributed.press/helloworld",
  "inReplyToAtomUri": null,
  "conversation": "tag:staticpub.distributed.press,2023-06-29:objectId=294618:objectType=Conversation",
  "content": "Hello, Fediverse! This is my first post.",
  "contentMap": {
    "en": "Hello, Fediverse! This is my first post."
  },
  "attachment": [],
  "tag": [],
  "replies": "https://staticpub.distributed.press/helloworld-replies.jsonld",
  "actor": "https://staticpub.distributed.press/about.jsonld"
}
Keypair being used: {
  publicKeyPem: '-----BEGIN PUBLIC KEY-----\n' +
    'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtZSfTeCr1Wv5NO9inU2O\n' +
    'k7yI+PHdBrpKrrsxQTXPfz1vWq6myObDKT+SKpxy86LBoY8Ow5/DfEW07vSQpeyq\n' +
    'YS6PhNzRTKFLe64YhQVMG9CFFnKt804pMe+DcGm4XZsPfaBWgPOkSw14vgLCusvE\n' +
    'MSa19+uUu4hW1zhFuHPfS2/HacANT3gXo9Qd3nyGd1Pap7zba9bBBbp2/V7ZJloC\n' +
    'LPO/2fvB0B9bcYebFN7AWsOnDDMwus2LKo5eTqiWAy8C9AissPzo9zGPseOhvBxP\n' +
    'z7MRJVOON5FZexFjv5b6UjUEqHBT+6Qb8H3WUo3RIrmfbX6rsLWJW5Lm+TJyV9kk\n' +
    'F0k/5nFIfYa5+DxbzvEFTRvaUEoxK2H4I+jA3an8sTb7uHCWQ5LeYzMEOwosfoL8\n' +
    'gtEuqQ47K+0fazPS87EfGYv7IAariDsV/9wQyPKODebkfsdJtdc9lyJT9a5uncqt\n' +
    'Tg9V30Z9rcwbRcA/YhRa45ZqB8N7Py6BBcHW/tpQ/AJeDc0UNoZn9rJBN3Lz3OTg\n' +
    '14aBwLme9ctaZ2MJR7o9np4qMJYBIyUP173eBOtUjXYENWmsfs2kt5lSGAbSSdRf\n' +
    'AdJmi2Hsbbk54T5BgkBsYZEDIUOPu9o/jxFKCW31nOIx1Kgi9b4i/hC3S/9PYx1T\n' +
    'WILtVslgUpWj+CXmhYES2mUCAwEAAQ==\n' +
    '-----END PUBLIC KEY-----\n',
  privateKeyPem: '-----BEGIN PRIVATE KEY-----\nBLAH-BLAH\n-----END PRIVATE KEY-----\n'
}
PublicKeyId being used: https://staticpub.distributed.press/about.jsonld#main-key
Social Inbox API Error: HTTP error! status: 500, message: {"statusCode":500,"error":"Internal Server Error","message":"fetch failed"}
Error sending post: HTTP error! status: 500, message: {"statusCode":500,"error":"Internal Server Error","message":"fetch failed"}

method: 'POST',
headers: {
'Content-Type': 'application/ld+json',
date: new Date().toUTCString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
date: new Date().toUTCString(),
date: new Date().toUTCString(),

Date and host are set by signed fetch. Just have the Content Type here.

@RangerMauve RangerMauve merged commit 181a95d into main Dec 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants