inbox import uses WoT

This commit is contained in:
Barry Deen
2024-09-23 12:56:04 -04:00
parent f27d2c1957
commit 4793abf3ed
2 changed files with 41 additions and 26 deletions

View File

@@ -85,22 +85,29 @@ func importTaggedNotes() {
}}
for ev := range pool.SubManyEose(ctx, config.ImportSeedRelays, filters) {
if !wotMap[ev.Event.PubKey] {
continue
}
for _, tag := range ev.Event.Tags.GetAll([]string{"p"}) {
if len(tag) < 2 {
continue
}
if tag[1] == nPubToPubkey(config.OwnerNpub) {
wdb.Publish(ctx, *ev.Event)
taggedImportedNotes++
}
}
}
log.Println("📦 imported", taggedImportedNotes, "tagged notes")
time.Sleep(5 * time.Second)
log.Println("📦 imported", taggedImportedNotes, "tagged notes")
time.Sleep(5 * time.Second)
startTime = startTime.Add(240 * time.Hour)
endTime = endTime.Add(240 * time.Hour)
startTime = startTime.Add(240 * time.Hour)
endTime = endTime.Add(240 * time.Hour)
if startTime.After(time.Now()) {
log.Println("✅ tagged import complete. please restart the relay")
break
if startTime.After(time.Now()) {
log.Println("✅ tagged import complete. please restart the relay")
break
}
}
}
}
@@ -120,23 +127,30 @@ func subscribeInbox() {
if !wotMap[ev.Event.PubKey] {
continue
}
wdb.Publish(ctx, *ev.Event)
switch ev.Event.Kind {
case nostr.KindTextNote:
log.Println("📰 new note in your inbox")
case nostr.KindReaction:
log.Println(ev.Event.Content, "new reaction in your inbox")
case nostr.KindZap:
log.Println("⚡️ new zap in your inbox")
case nostr.KindEncryptedDirectMessage:
log.Println("🔒 new encrypted message in your inbox")
case nostr.KindRepost:
log.Println("🔁 new repost in your inbox")
case nostr.KindFollowList:
// do nothing
default:
log.Println("📦 new event in your inbox")
for _, tag := range ev.Event.Tags.GetAll([]string{"p"}) {
if len(tag) < 2 {
continue
}
if tag[1] == nPubToPubkey(config.OwnerNpub) {
wdb.Publish(ctx, *ev.Event)
switch ev.Event.Kind {
case nostr.KindTextNote:
log.Println("📰 new note in your inbox")
case nostr.KindReaction:
log.Println(ev.Event.Content, "new reaction in your inbox")
case nostr.KindZap:
log.Println("⚡️ new zap in your inbox")
case nostr.KindEncryptedDirectMessage:
log.Println("🔒 new encrypted message in your inbox")
case nostr.KindRepost:
log.Println("🔁 new repost in your inbox")
case nostr.KindFollowList:
// do nothing
default:
log.Println("📦 new event in your inbox")
}
taggedImportedNotes++
}
}
}
}

View File

@@ -29,6 +29,8 @@ func main() {
log.Println("🚀 haven is booting up")
initRelays()
refreshTrustNetwork()
if *importFlag {
log.Println("📦 importing notes")
importOwnerNotes()
@@ -36,7 +38,6 @@ func main() {
return
}
go refreshTrustNetwork()
go subscribeInbox()
go backupDatabase()