Skip to content

Commit

Permalink
update nostr-geotags
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Jul 27, 2024
1 parent 9b17f63 commit 1a3ccba
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apps/nocapd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions apps/nocapd/src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/publisher/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"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",
"repository": "http://github.com/sandwichfarm/nostr-watch",
"author": "sandwich <[email protected]> ",
"license": "MIT",
"dependencies": {
"nostr-geotags": "^0.5.0",
"nostr-geotags": "^0.7.1",
"nostr-tools": "1.17.0"
}
}
16 changes: 2 additions & 14 deletions internal/publisher/src/kinds/Kind10166.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

}
12 changes: 3 additions & 9 deletions internal/publisher/src/kinds/Kind30166.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PublisherNocap } from '../Publisher.js'
import ngeotags from 'nostr-geotags';

export class Kind30166 extends PublisherNocap {
constructor(){
Expand Down Expand Up @@ -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'])

Expand Down
24 changes: 24 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,22 @@
get-ssl-cert "2.3.3"
ssl-checker "2.0.8"

"@nostrwatch/[email protected]":
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/[email protected]":
version "0.4.3"
resolved "https://registry.npmjs.org/@nostrwatch/publisher/-/publisher-0.4.3.tgz#4c26eef5fb281ead3bce5433248ddf7e2cbde130"
Expand Down Expand Up @@ -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"

[email protected], 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"
Expand Down

0 comments on commit 1a3ccba

Please sign in to comment.