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

Update config (add Crust) #232

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deployment/overlays/production/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ data:
IPFS_CLUSTER_URL: http://new-ipfs-cluster:9094
IPFS_GATEWAY_URL: https://ipfs.subsocial.network
IPFS_MAX_FILE_SIZE_BYTES: "2097152"
IPFS_NODE_URL: http://new-ipfs-cluster:5001
IPFS_NODE_URL: https://ipfs-gw.decloud.foundation
IPFS_READ_ONLY_NODE_URL: http://new-ipfs-cluster:8080
IPFS_CRUST_AUTH: ''
IPFS_CRUST_AUTH: 'Basic c3ViLTVGQTluUURWZzI2N0RFZDhtMVp5cFhMQm52TjdTRnhZd1Y3bmRxU1lHaU45VFRwdToweDEwMmQ3ZmJhYWQwZGUwNzFjNDFmM2NjYzQzYmQ0NzIxNzFkZGFiYWM0MzEzZTc5YTY3ZWExOWM0OWFlNjgyZjY0YWUxMmRlY2YyNzhjNTEwZGY4YzZjZTZhYzdlZTEwNzY2N2YzYTBjZjM5OGUxN2VhMzAyMmRkNmEyYjc1OTBi='
KUSAMA_NODE_URL: wss://kusama-rpc.polkadot.io
LOG_LEVEL: info
MAX_RESULTS_LIMIT: "20"
Expand Down
11 changes: 5 additions & 6 deletions src/ipfs/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SubsocialIpfsApi } from '@subsocial/api'
import {crustIpfsAuth, ipfsClusterUrl, ipfsNodeUrl, ipfsReadOnlyNodeUrl} from "../env";

function getIpfsApi() {
const headers = crustIpfsAuth ? { authorization: `Bearer ${crustIpfsAuth}` } : {}
const writeHeaders = crustIpfsAuth ? { authorization: crustIpfsAuth } : {}
const props = crustIpfsAuth ? { asLink: false, 'meta.gatewayId': 1 } : { asLink: true }

console.log(props)
Expand All @@ -10,21 +11,19 @@ function getIpfsApi() {
ipfsNodeUrl: ipfsReadOnlyNodeUrl,
ipfsAdminNodeUrl: ipfsNodeUrl,
ipfsClusterUrl,
headers,
})
ipfs.setWriteHeaders(headers)
ipfs.setPinHeaders(headers)
ipfs.setWriteHeaders(writeHeaders)

return {
ipfs,
saveAndPinJson: async (content: Record<any, any>) => {
const cid = await ipfs.saveJson(content)
await ipfs.pinContent(cid, props)
ipfs.pinContent(cid, props)
return cid
},
saveAndPinFile: async (file: any) => {
const cid = await ipfs.saveFile(file)
await ipfs.pinContent(cid, props)
ipfs.pinContent(cid, props)
return cid
},
}
Expand Down
Loading