Add setProfile and sync helper

This commit is contained in:
Jon Staab
2025-07-15 21:26:53 -07:00
parent fd84b80734
commit 2ed88c3345
3 changed files with 59 additions and 27 deletions
+14 -1
View File
@@ -15,6 +15,9 @@ import {
makeRoomEditEvent,
makeRoomJoinEvent,
makeRoomLeaveEvent,
isPublishedProfile,
createProfile,
editProfile,
RelayMode,
INBOX_RELAYS,
FOLLOWS,
@@ -22,7 +25,7 @@ import {
MUTES,
PINS,
} from "@welshman/util"
import type {RoomMeta} from "@welshman/util"
import type {RoomMeta, Profile} from "@welshman/util"
import {Nip59, stamp} from "@welshman/signer"
import {Router, addMaximalFallbacks} from "@welshman/router"
import {
@@ -86,6 +89,16 @@ export const addInboxRelay = async (url: string) => {
return publishThunk({event, relays})
}
// NIP 01
export const setProfile = (profile: Profile) => {
const router = Router.get()
const relays = router.merge([router.Index(), router.FromUser()]).getUrls()
const event = isPublishedProfile(profile) ? editProfile(profile) : createProfile(profile)
return publishThunk({event, relays})
}
// NIP 02
export const unfollow = async (value: string) => {