Skip to content

Commit

Permalink
Update internal dependencies with actual versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Sep 25, 2024
1 parent 6a5304d commit a718902
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .changeset/hot-spiders-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@nostrwatch/nostrings': minor
'@nostrwatch/nwcache': minor
'@nostrwatch/trawler': minor
'@nostrwatch/nocapd': minor
---

relay urls with usernames were slipping through, migrations and fix sanitizer
14 changes: 8 additions & 6 deletions apps/nocapd/src/migrate/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { MigrationFixRelayDuplicates } from './migrations/fix-non-normal-urls.js'
import { FindClosestToRoot } from '@nostrwatch/nwcache/migrations/duplicates.js'
import { AddIgnoreFieldToRelays } from '@nostrwatch/nwcache/migrations/add_ignore_field_to_relays.js'
import { SanitizeRelayUrls } from '@nostrwatch/nwcache/migrations/sanitize.js'
// import { MigrationFixRelayDuplicates } from './migrations/fix-non-normal-urls.js'
// import { FindClosestToRoot } from '@nostrwatch/nwcache/migrations/duplicates.js'
import { MigrationFixUsernamesInUrls } from '@nostrwatch/nwcache/migrations/fix_usernames_in_urls.js'
// import { AddIgnoreFieldToRelays } from '@nostrwatch/nwcache/migrations/add_ignore_field_to_relays.js'
// import { SanitizeRelayUrls } from '@nostrwatch/nwcache/migrations/sanitize.js'

export default async(rcache) => {
await MigrationFixRelayDuplicates(rcache)
// await MigrationFixRelayDuplicates(rcache)
// await AddIgnoreFieldToRelays(rcache)
// await SanitizeRelayUrls(rcache)
await FindClosestToRoot(rcache)
await MigrationFixUsernamesInUrls(rcache)
// await FindClosestToRoot(rcache)
}
13 changes: 13 additions & 0 deletions apps/nocapd/src/migrate/migrations/fix-usernames-in-urls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const MigrationFixUsernamesInUrls = async (rcache) => {
const allRelays = await rcache.relay.get.all(['url']).map( relay => relay.url )
const deleted = []
for(const relay of allRelays) {
const url = new URL(relay)
if(url.username !== '') {
// deleted.push(await rcache.relay.delete(relay))
deleted.push(relay)
}
}
console.log(`deleted ${deleted.length} usernames from urls`)
console.log(deleted)
}
5 changes: 5 additions & 0 deletions apps/trawler/src/migrate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MigrationFixUsernamesInUrls } from '@nostrwatch/nwcache/migrations/fix_usernames_in_urls.js'

export default async(rcache) => {
await MigrationFixUsernamesInUrls(rcache)
}
4 changes: 3 additions & 1 deletion apps/trawler/src/trawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { nostrawl } from 'nostrawl'
import Logger from '@nostrwatch/logger'
import cacheInit from '@nostrwatch/nwcache'
import { bootstrap } from '@nostrwatch/seed'
import Migrations from './migrate.js'

import { addRelaysToCache, relaysFromRelayList } from './helpers.js'

Expand Down Expand Up @@ -80,9 +81,10 @@ const validator = ($trawler, event) => {
return noteIsUnknown? ACCEPT: REJECT
}

const after_cacheOpen = (trawlerCache) => {
const after_cacheOpen = async (trawlerCache) => {
logger.info('after_cacheOpen(): adding nw extensions to nostrawl cache')
$cache = cacheInit(trawlerCache)
await Migrations($cache)
}

export const trawl = async () => {
Expand Down
13 changes: 13 additions & 0 deletions internal/nwcache/migrations/fix_usernames_in_urls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const MigrationFixUsernamesInUrls = async (rcache) => {
const allRelays = await rcache.relay.get.all(['url']).map( relay => relay.url )
const deleted = []
for(const relay of allRelays) {
const url = new URL(relay)
if(url.username !== '') {
deleted.push(await rcache.relay.delete(relay))
// deleted.push(relay)
}
}
console.log(`deleted ${deleted.length} usernames from urls`)
console.log(deleted)
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11242,6 +11242,11 @@ [email protected]:
resolved "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz#d1cd774f36fbc07165066a60e40323eab6446fd4"
integrity sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==

[email protected]:
version "8.17.1"
resolved "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==

[email protected]:
version "8.18.0"
resolved "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
Expand Down

0 comments on commit a718902

Please sign in to comment.