Compare commits
No commits in common. "35435296003f6de9229b30a4998fa3cea8443fee" and "cc3afe1eaa27133e973e7077272f3e0f53ae5bfe" have entirely different histories.
3543529600
...
cc3afe1eaa
1 changed files with 16 additions and 19 deletions
35
main.ts
35
main.ts
|
@ -54,7 +54,7 @@ const relay = new NRelay1(relay_str);
|
|||
|
||||
console.log("\nAs a sanity check, here's your last message (if any):");
|
||||
|
||||
for await (const msg of relay.req([{ kinds: [1], limit: 1, authors: [pubkey_hex] }])) {
|
||||
for await (const msg of relay.req([{ kinds: [1], limit: 960, authors: [pubkey_hex] }])) {
|
||||
if (msg[0] === 'EVENT') console.log(msg[2].content);
|
||||
if (msg[0] === 'EOSE') break;
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ for (const i in posts) {
|
|||
|
||||
// Populated from the first media item with coordinates
|
||||
let geotags;
|
||||
let event_tags: string[][] = [];
|
||||
|
||||
let first = true;
|
||||
for (const j in post.media) {
|
||||
|
@ -140,27 +139,23 @@ for (const i in posts) {
|
|||
|
||||
if (geotags == undefined && media.media_metadata && media.media_metadata.photo_metadata) {
|
||||
const options = {
|
||||
geohash: true, // l tag per NIP-52, adds multiple tags at decreasing resolution
|
||||
gps: false, // Avoid multiple tags, insert them manually below.
|
||||
geohash: true,
|
||||
gps: true,
|
||||
city: false,
|
||||
iso31662: false,
|
||||
iso31662: false,
|
||||
iso31663: false
|
||||
};
|
||||
|
||||
const exif_data = media.media_metadata.photo_metadata.exif_data;
|
||||
let exif_data = media.media_metadata.photo_metadata.exif_data;
|
||||
if (exif_data) {
|
||||
for (const k in exif_data) {
|
||||
const exif_item = exif_data[k];
|
||||
if (exif_item.latitude != undefined && exif_item.latitude != undefined) {
|
||||
// Add coordinates as a tag.
|
||||
// There is currently no NIP defining a wgs84 tag!
|
||||
event_tags.push(['wgs84', String(exif_item.latitude), String(exif_item.longitude)])
|
||||
// Encode coordinates as Geohash in different resolutions:
|
||||
// https://en.wikipedia.org/wiki/Geohash
|
||||
event_tags = [...event_tags, ...ngeotags({
|
||||
geotags = ngeotags({
|
||||
lat: exif_item.latitude,
|
||||
lon: exif_item.longitude
|
||||
}, options)];
|
||||
}, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,12 +166,15 @@ for (const i in posts) {
|
|||
let event = {
|
||||
kind: 1,
|
||||
content: message,
|
||||
tags: event_tags,
|
||||
tags: [],
|
||||
created_at: created_at
|
||||
}
|
||||
if (geotags != undefined) {
|
||||
event.tags = [...event.tags, ...geotags];
|
||||
}
|
||||
const signed_event = await signer.signEvent(event);
|
||||
console.log(signed_event);
|
||||
events.push(signed_event);
|
||||
console.log(event);
|
||||
events.push(event);
|
||||
|
||||
completed++;
|
||||
if (completed == n) break;
|
||||
|
@ -184,10 +182,9 @@ for (const i in posts) {
|
|||
|
||||
alert("About to post to Nostr.");
|
||||
|
||||
for (const i in events) {
|
||||
const event = events[i]
|
||||
await relay.event(event);
|
||||
console.log(event.id);
|
||||
for (const event in events) {
|
||||
console.log(event);
|
||||
console.log(await relay.event(event));
|
||||
}
|
||||
|
||||
await relay.close()
|
||||
|
|
Loading…
Reference in a new issue