Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from "src/engine/utils"
export * from "src/engine/state"
export * from "src/engine/requests"
export * from "src/engine/commands"
export * from "src/engine/projections"
29 changes: 0 additions & 29 deletions src/engine/projections.ts

This file was deleted.

17 changes: 17 additions & 0 deletions src/engine/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
subscribe as baseSubscribe,
db,
displayProfileByPubkey,
ensurePlaintext,
followsByPubkey,
freshness,
getDefaultAppContext,
Expand Down Expand Up @@ -71,6 +72,7 @@ import {
HANDLER_RECOMMENDATION,
LABEL,
LOCAL_RELAY_URL,
MUTES,
NAMED_BOOKMARKS,
SEEN_CONTEXT,
SEEN_CONVERSATION,
Expand Down Expand Up @@ -156,6 +158,21 @@ export const projections = new Worker<TrustedEvent>({
getKey: prop("kind"),
})

projections.addGlobalHandler(ensurePlaintext)

const decryptKinds = [SEEN_GENERAL, SEEN_CONTEXT, SEEN_CONVERSATION, APP_DATA, FOLLOWS, MUTES]

// Synchronize repository with projections. All events should be published to the
// repository, and when accepted, be propagated to projections. This avoids processing
// the same event multiple times, since repository deduplicates
repository.on("update", ({added}: {added: TrustedEvent[]}) => {
for (const event of added) {
if (decryptKinds.includes(event.kind)) {
projections.push(event)
}
}
})

// Plaintext

export const ensureMessagePlaintext = async (e: TrustedEvent) => {
Expand Down