-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7ca731
commit 7fd8449
Showing
6 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { gql } from "https://deno.land/x/[email protected]/mod.ts"; | |
|
||
export const typeDefs = gql` | ||
type Query { | ||
events(pubkey: String, offset: Int, limit: Int): Events | ||
events(pubkey: [String!]!, offset: Int, limit: Int): Events | ||
event(id: String): Event | ||
policies: [Policy] | ||
relayInformation: RelayInformation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
run: fmt | ||
deno task run | ||
deno run --check --allow-net --allow-env --unstable deploy/default.ts | ||
|
||
fmt: | ||
deno fmt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,11 @@ import { | |
NostrFilter, | ||
NostrKind, | ||
prepareNormalNostrEvent, | ||
PublicKey, | ||
} from "../_libs.ts"; | ||
import { EventReadWriter } from "../main.tsx"; | ||
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts"; | ||
|
||
export type Actor = { | ||
type: "admin"; | ||
} | { | ||
type: "user"; | ||
npub: string; | ||
}; | ||
|
||
type Pagination = { | ||
offset?: number | undefined; | ||
limit?: number | undefined; | ||
}; | ||
|
||
export type func_GetEventsByIDs = (ids: Set<string>) => AsyncIterable<NostrEvent>; | ||
export type interface_GetEventsByIDs = { | ||
get_events_by_IDs: func_GetEventsByIDs; | ||
|
@@ -65,8 +54,16 @@ export class EventStore implements EventReadWriter { | |
} | ||
|
||
async *get_events_by_authors(authors: Set<string>): AsyncIterable<NostrEvent> { | ||
const hex_keys = new Set(); | ||
for (const author of authors) { | ||
const key = PublicKey.FromString(author); | ||
if (key instanceof Error) { | ||
continue; | ||
} | ||
hex_keys.add(key.hex); | ||
} | ||
for (const event of this.events.values()) { | ||
if (authors.has(event.pubkey)) { | ||
if (hex_keys.has(event.pubkey)) { | ||
yield event; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters