Skip to content

Commit

Permalink
feat(ipns): use MATTERS_SITE_DOMAIN_PREFIX instead of hardcode
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwoz committed Nov 6, 2024
1 parent e5c60e4 commit 38cd48d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/refresh-ipns-gw3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ export async function refreshPinLatest({
dataHash && {
userName,
dataHash,
path: `matters.town/@${userName}/${id}-${slugify(title)}`,
path: `${
process.env.MATTERS_SITE_DOMAIN_PREFIX
}/@${userName}/${id}-${slugify(title)}`,
...(await gw3Client.getPin(dataHash)),
}
)
Expand Down Expand Up @@ -454,7 +456,9 @@ export async function refreshPinLatest({
dataHash && {
userName,
dataHash,
path: `matters.town/@${userName}/${id}-${slugify(title)}`,
path: `${
process.env.MATTERS_SITE_DOMAIN_PREFIX
}/@${userName}/${id}-${slugify(title)}`,
...(statusByCid.get(dataHash)?.status in skipStatuses
? statusByCid.get(dataHash)
: await gw3Client.addPin(
Expand All @@ -481,7 +485,9 @@ export async function refreshPinLatest({
dataHash && {
userName,
dataHash,
path: `matters.town/@${userName}/${id}-${slugify(title)}`,
path: `${
process.env.MATTERS_SITE_DOMAIN_PREFIX
}/@${userName}/${id}-${slugify(title)}`,
...(await gw3Client.getPin(dataHash)),
}
)
Expand Down Expand Up @@ -1062,7 +1068,7 @@ export async function refreshIPNSFeed(

let lastCidData = await gw3Client.addPinWait(
lastCid,
`matters.town/@${author.userName}-lastest-top-dir-hash`
`${process.env.MATTERS_SITE_DOMAIN_PREFIX}/@${author.userName}-lastest-top-dir-hash`
)
if (lastCidData?.status !== 'pinned') {
console.log(
Expand Down Expand Up @@ -1095,7 +1101,9 @@ export async function refreshIPNSFeed(
gw3Client
.addPin(
arti.dataHash,
`matters.town/@${author.userName}/${arti.id}-${slugify(arti.title)}`
`${process.env.MATTERS_SITE_DOMAIN_PREFIX}/@${author.userName}/${
arti.id
}-${slugify(arti.title)}`
)
.then((resData) => {
if (resData?.code !== 200) {
Expand Down Expand Up @@ -1288,7 +1296,7 @@ export async function refreshIPNSFeed(

let resIPNS

const topAuthorDirName = `matters.town/@${author.userName}` // ${ extraBundles.length > 0 ? `@${dateSuffix}` : "" }`;
const topAuthorDirName = `${process.env.MATTERS_SITE_DOMAIN_PREFIX}/@${author.userName}` // ${ extraBundles.length > 0 ? `@${dateSuffix}` : "" }`;
{
// check & delete if exists
const res = await gw3Client.getIpnsByName(topAuthorDirName)
Expand Down

0 comments on commit 38cd48d

Please sign in to comment.