From 1a3ccba3b77e26fb87805536429f7f437a76baff Mon Sep 17 00:00:00 2001 From: dskvr Date: Sat, 27 Jul 2024 21:03:50 +0200 Subject: [PATCH] update nostr-geotags --- apps/nocapd/package.json | 2 +- apps/nocapd/src/daemon.js | 4 +--- internal/publisher/package.json | 4 ++-- internal/publisher/src/kinds/Kind10166.js | 16 ++------------- internal/publisher/src/kinds/Kind30166.js | 12 +++--------- yarn.lock | 24 +++++++++++++++++++++++ 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/apps/nocapd/package.json b/apps/nocapd/package.json index 0a851e2c..f96c7558 100644 --- a/apps/nocapd/package.json +++ b/apps/nocapd/package.json @@ -12,7 +12,7 @@ "@nostrwatch/nocap": "0.5.3", "@nostrwatch/nocap-every-adapter-default": "1.4.0", "@nostrwatch/nwcache": "0.1.2", - "@nostrwatch/publisher": "0.5.2", + "@nostrwatch/publisher": "0.5.4", "@nostrwatch/seed": "0.0.2", "@nostrwatch/utils": "0.1.3", "bluebird": "3.7.2", diff --git a/apps/nocapd/src/daemon.js b/apps/nocapd/src/daemon.js index 964b28bb..58036179 100644 --- a/apps/nocapd/src/daemon.js +++ b/apps/nocapd/src/daemon.js @@ -197,15 +197,13 @@ async function gracefulShutdown(signal) { process.exit(9); } - - export const Nocapd = async () => { config = await loadConfig().catch( (err) => { log.err(err); process.exit() } ) await delay(2000) rcache = relaycache(process.env.NWCACHE_PATH || './.lmdb') await migrate(rcache) await delay(1000) - await maybeAnnounce() + // await maybeAnnounce() await maybeBootstrap() $q = await initWorker() $q.worker.on('drained', populateQueue) diff --git a/internal/publisher/package.json b/internal/publisher/package.json index 0f9f2dbb..6461a8b0 100644 --- a/internal/publisher/package.json +++ b/internal/publisher/package.json @@ -1,6 +1,6 @@ { "name": "@nostrwatch/publisher", - "version": "0.5.2", + "version": "0.5.4", "type": "module", "description": "Library for publishing nostr.watch relay status and publisher registration events", "main": "index.js", @@ -8,7 +8,7 @@ "author": "sandwich ", "license": "MIT", "dependencies": { - "nostr-geotags": "^0.5.0", + "nostr-geotags": "^0.7.1", "nostr-tools": "1.17.0" } } diff --git a/internal/publisher/src/kinds/Kind10166.js b/internal/publisher/src/kinds/Kind10166.js index 3ba261bb..6cc1c7aa 100644 --- a/internal/publisher/src/kinds/Kind10166.js +++ b/internal/publisher/src/kinds/Kind10166.js @@ -48,21 +48,9 @@ export class Kind10166 extends Publisher { data?.checks.map(check => check.toString()).forEach(check => tags.push(["c", check])); if(data?.timeouts) Object.keys(data?.timeouts || []).map(key => [ key, data.timeouts[key] ]).forEach(timeout => tags.push([ "timeout", timeout[0], timeout[1].toString() ] )); - // if(data?.geo && data.geo instanceof Object) - // tags = [...tags, ...ngeotags(data.geo, geoOpts)]; + if(data?.geo && data.geo instanceof Object) + tags = [...tags, ...ngeotags(data.geo, geoOpts)]; return tags; } - static parse(event){ - return { - frequency: event.tags.find(tag => tag[0] === 'frequency')?.[1], - owner: event.tags.find(tag => tag[0] === 'o')?.[1], - kinds: event.tags.filter(tag => tag[0] === 'k').map(tag => tag[1]), - counts: event.tags.filter(tag => tag[0] === 'n').map(tag => tag[1]), - checks: event.tags.filter(tag => tag[0] === 'c').map(tag => tag[1]), - timeouts: event.tags.filter(tag => tag[0] === 'timeout').reduce((acc, tag) => { acc[tag[1]] = parseInt(tag[2]); return acc; }, {}), - geo: ngeotags.parse(event.tags) - } - } - } diff --git a/internal/publisher/src/kinds/Kind30166.js b/internal/publisher/src/kinds/Kind30166.js index 0dacccbb..0fe845ad 100644 --- a/internal/publisher/src/kinds/Kind30166.js +++ b/internal/publisher/src/kinds/Kind30166.js @@ -1,4 +1,5 @@ import { PublisherNocap } from '../Publisher.js' +import ngeotags from 'nostr-geotags'; export class Kind30166 extends PublisherNocap { constructor(){ @@ -131,15 +132,8 @@ export class Kind30166 extends PublisherNocap { tags.push(['l', data.geo?.data?.asname, 'host.asn']) } - if (data?.geo?.data?.countryCode){ - tags.push(['L', 'ISO-3166-1:alpha-2']) - tags.push(['l', data?.geo?.data?.countryCode, 'ISO-3166-1:alpha-2']) - } - - if (data?.geo?.data?.cityName){ - tags.push(['L', 'watch.nostr.cityName']) - tags.push(['l', data?.geo?.data?.cityName, 'watch.nostr.cityName']) - } + if(data?.geo?.data && data.geo.data instanceof Object) + tags = [...tags, ...ngeotags(data.geo.data, {isoAsNamespace: false})]; tags.push(['l', 'draft7', 'nip66.draft']) diff --git a/yarn.lock b/yarn.lock index da762623..3418b13c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1870,6 +1870,22 @@ get-ssl-cert "2.3.3" ssl-checker "2.0.8" +"@nostrwatch/nocap@0.5.2": + version "0.5.2" + resolved "https://registry.npmjs.org/@nostrwatch/nocap/-/nocap-0.5.2.tgz#6dac7ad9b1c266e0fd7cf06c91b4aa140ee3cf54" + integrity sha512-6HY/RCJ/WU+KxhAETXXS9XHW6O9DsR4d82flOxWW9/lpiV5KrXoq6Wm8ISGQ+mkOrdhU4eZMiLGTZ7faDwavzw== + dependencies: + "@nostrwatch/logger" "0.0.6" + "@nostrwatch/nocap-every-adapter-default" "^1.3.1" + fetch-h2 "3.0.2" + get-ssl-certificate "2.3.3" + jest "29.7.0" + murmurhash "^2.0.1" + object-hash "3.0.0" + promise-deferred "2.0.4" + socks-proxy-agent "8.0.2" + ws "8.16.0" + "@nostrwatch/publisher@0.4.3": version "0.4.3" resolved "https://registry.npmjs.org/@nostrwatch/publisher/-/publisher-0.4.3.tgz#4c26eef5fb281ead3bce5433248ddf7e2cbde130" @@ -7302,6 +7318,14 @@ nostr-geotags@^0.5.0: iso-3166 "4.3.0" ngeohash "0.6.3" +nostr-geotags@^0.7.1: + version "0.7.1" + resolved "https://registry.npmjs.org/nostr-geotags/-/nostr-geotags-0.7.1.tgz#0ea8336b45d67f7aa0d096564581bc89cd908997" + integrity sha512-3xnmDUqTP7MzWLmaJvTgWYwlex3yYGmKi6qAEOHRrh+gZs26YEqECe5yalRH0i4rBZXNXDfkiZs/gvRts6eoAQ== + dependencies: + iso-3166 "4.3.0" + ngeohash "0.6.3" + nostr-tools@1.17.0, nostr-tools@^1.14.0, nostr-tools@^1.15.0: version "1.17.0" resolved "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.17.0.tgz#b6f62e32fedfd9e68ec0a7ce57f74c44fc768e8c"