Use welshman kinds

This commit is contained in:
Jon Staab
2026-04-16 11:30:59 -07:00
parent 7a7af58f5c
commit e1a7b051bd
19 changed files with 163 additions and 214 deletions
+9 -25
View File
@@ -18,7 +18,6 @@ import {
import {Nip01Signer} from "@welshman/signer"
import type {UploadTask} from "@welshman/editor"
import type {TrustedEvent, EventContent, Profile, PublishedRoomMeta} from "@welshman/util"
import {PollResponse} from "nostr-tools/kinds"
import {
DELETE,
REPORT,
@@ -33,6 +32,7 @@ import {
ROOMS,
COMMENT,
APP_DATA,
POLL_RESPONSE,
isSignedEvent,
makeEvent,
normalizeRelayUrl,
@@ -53,7 +53,6 @@ import {
isPublishedProfile,
editProfile,
createProfile,
uniqTags,
ManagementMethod,
} from "@welshman/util"
import {Pool, AuthStatus, SocketStatus} from "@welshman/net"
@@ -85,6 +84,7 @@ import {
SETTINGS,
PROTECTED,
INDEXER_RELAYS,
DEFAULT_RELAYS,
DEFAULT_BLOSSOM_SERVERS,
userSpaceUrls,
userSettingsValues,
@@ -389,7 +389,7 @@ export type PollResponseParams = {
}
export const makePollResponse = ({event, selectedIds}: PollResponseParams) =>
makeEvent(PollResponse, {
makeEvent(POLL_RESPONSE, {
content: "",
tags: [["e", event.id], ...selectedIds.map(selectedId => ["response", selectedId])],
})
@@ -724,34 +724,18 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
// Update Profile
export const initProfile = (profile: Profile) => {
const template = createProfile(profile)
const event = makeEvent(PROFILE, createProfile(profile))
// Start out protected by default
template.tags.push(PROTECTED)
const event = makeEvent(PROFILE, template)
// Don't publish anywhere yet, wait until they join a space
return publishThunk({event, relays: []})
return publishThunk({event, relays: DEFAULT_RELAYS})
}
export const updateProfile = ({
profile,
shouldBroadcast = !getTag(PROTECTED, profile.event?.tags || []),
}: {
profile: Profile
shouldBroadcast?: boolean
}) => {
export const updateProfile = ({profile}: {profile: Profile}) => {
const router = Router.get()
const template = isPublishedProfile(profile) ? editProfile(profile) : createProfile(profile)
const scenarios = [router.FromRelays(get(userSpaceUrls))]
const scenarios = [router.FromRelays(get(userSpaceUrls)), router.FromUser(), router.Index()]
if (shouldBroadcast) {
scenarios.push(router.FromUser(), router.Index())
template.tags = template.tags.filter(nthNe(0, "-"))
} else {
template.tags = uniqTags([...template.tags, PROTECTED])
}
// Remove protected tag, we used to add it
template.tags = template.tags.filter(nthNe(0, "-"))
const event = makeEvent(template.kind, template)
const relays = router.merge(scenarios).getUrls()
+2 -2
View File
@@ -3,7 +3,6 @@ import {context as pomadeContext} from "@pomade/core"
import {Capacitor} from "@capacitor/core"
import {derived, readable, writable} from "svelte/store"
import * as nip19 from "nostr-tools/nip19"
import {Poll} from "nostr-tools/kinds"
import {
on,
gt,
@@ -93,6 +92,7 @@ import {
THREAD,
CLASSIFIED,
WRAP,
POLL,
PROFILE,
ZAP_GOAL,
ZAP_REQUEST,
@@ -327,7 +327,7 @@ if (ENABLE_ZAPS) {
REACTION_KINDS.push(ZAP_RESPONSE)
}
export const CONTENT_KINDS = [ZAP_GOAL, EVENT_TIME, THREAD, CLASSIFIED, Poll]
export const CONTENT_KINDS = [ZAP_GOAL, EVENT_TIME, THREAD, CLASSIFIED, POLL]
export const DM_KINDS = [DIRECT_MESSAGE, DIRECT_MESSAGE_FILE]
+2 -2
View File
@@ -1,7 +1,6 @@
import {page} from "$app/stores"
import type {Unsubscriber} from "svelte/store"
import {last, call, assoc, chunk, WEEK, ago} from "@welshman/lib"
import {PollResponse} from "nostr-tools/kinds"
import {merged} from "@welshman/store"
import {
getListTags,
@@ -20,6 +19,7 @@ import {
RELAY_ADD_MEMBER,
RELAY_REMOVE_MEMBER,
MESSAGE,
POLL_RESPONSE,
isSignedEvent,
unionFilters,
} from "@welshman/util"
@@ -280,7 +280,7 @@ const syncSpace = (url: string) => {
filters: [
{kinds: [...relayKinds, ...roomMetaKinds, ...roomDeleteKinds, ...CONTENT_KINDS, MESSAGE]},
makeCommentFilter(CONTENT_KINDS, {since}),
{kinds: [...REACTION_KINDS, PollResponse], since},
{kinds: [...REACTION_KINDS, POLL_RESPONSE], since},
],
})