replace queue with worker

This commit is contained in:
Jon Staab
2024-03-26 11:35:30 -07:00
parent 0b5a4e8511
commit bc21228f04
7 changed files with 144 additions and 126 deletions
+8 -2
View File
@@ -17,7 +17,13 @@ export const isShareableRelayUrl = (url: string) =>
!url.slice(6).match(/\/npub/)
)
export const normalizeRelayUrl = (url: string) => {
type NormalizeRelayUrlOpts = {
allowInsecure?: boolean
}
export const normalizeRelayUrl = (url: string, {allowInsecure = false}: NormalizeRelayUrlOpts = {}) => {
const prefix = allowInsecure ? url.match(/^wss?:\/\//)?.[0] || "wss://" : "wss://"
// Use our library to normalize
url = normalizeUrl(url, {stripHash: true, stripAuthentication: false})
@@ -29,5 +35,5 @@ export const normalizeRelayUrl = (url: string) => {
url += "/"
}
return "wss://" + url
return prefix + url
}
+1 -1
View File
@@ -78,7 +78,7 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
entries = () => this.mapTo(t => t.entry())
relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl).map(normalizeRelayUrl)).uniq()
relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl).map(url => normalizeRelayUrl(url))).uniq()
topics = () => this.whereKey("t").values().map((t: string) => t.replace(/^#/, ""))