rename createEvent to makeEvent
This commit is contained in:
parent
5718510779
commit
a22db78967
12 changed files with 37 additions and 37 deletions
BIN
pnpm-lock.yaml
BIN
pnpm-lock.yaml
Binary file not shown.
|
|
@ -19,7 +19,7 @@ import {
|
||||||
GROUPS,
|
GROUPS,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
isSignedEvent,
|
isSignedEvent,
|
||||||
createEvent,
|
makeEvent,
|
||||||
displayProfile,
|
displayProfile,
|
||||||
normalizeRelayUrl,
|
normalizeRelayUrl,
|
||||||
makeList,
|
makeList,
|
||||||
|
|
@ -129,13 +129,13 @@ export const broadcastUserData = async (relays: string[]) => {
|
||||||
// NIP 29 stuff
|
// NIP 29 stuff
|
||||||
|
|
||||||
export const createRoom = (url: string, room: string) => {
|
export const createRoom = (url: string, room: string) => {
|
||||||
const event = createEvent(GROUP_CREATE, {tags: [tagRoom(room, url)]})
|
const event = makeEvent(GROUP_CREATE, {tags: [tagRoom(room, url)]})
|
||||||
|
|
||||||
return publishThunk({event, relays: [url]})
|
return publishThunk({event, relays: [url]})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const editRoom = (url: string, room: string, meta: Record<string, string>) => {
|
export const editRoom = (url: string, room: string, meta: Record<string, string>) => {
|
||||||
const event = createEvent(GROUP_EDIT_META, {
|
const event = makeEvent(GROUP_EDIT_META, {
|
||||||
tags: [tagRoom(room, url), ...Object.entries(meta)],
|
tags: [tagRoom(room, url), ...Object.entries(meta)],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -143,13 +143,13 @@ export const editRoom = (url: string, room: string, meta: Record<string, string>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const joinRoom = (url: string, room: string) => {
|
export const joinRoom = (url: string, room: string) => {
|
||||||
const event = createEvent(GROUP_JOIN, {tags: [tagRoom(room, url)]})
|
const event = makeEvent(GROUP_JOIN, {tags: [tagRoom(room, url)]})
|
||||||
|
|
||||||
return publishThunk({event, relays: [url]})
|
return publishThunk({event, relays: [url]})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const leaveRoom = (url: string, room: string) => {
|
export const leaveRoom = (url: string, room: string) => {
|
||||||
const event = createEvent(GROUP_LEAVE, {tags: [tagRoom(room, url)]})
|
const event = makeEvent(GROUP_LEAVE, {tags: [tagRoom(room, url)]})
|
||||||
|
|
||||||
return publishThunk({event, relays: [url]})
|
return publishThunk({event, relays: [url]})
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return publishThunk({
|
return publishThunk({
|
||||||
event: createEvent(list.kind, {tags}),
|
event: makeEvent(list.kind, {tags}),
|
||||||
relays: [
|
relays: [
|
||||||
url,
|
url,
|
||||||
...INDEXER_RELAYS,
|
...INDEXER_RELAYS,
|
||||||
|
|
@ -229,7 +229,7 @@ export const setInboxRelayPolicy = (url: string, enabled: boolean) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return publishThunk({
|
return publishThunk({
|
||||||
event: createEvent(list.kind, {tags}),
|
event: makeEvent(list.kind, {tags}),
|
||||||
relays: [
|
relays: [
|
||||||
...INDEXER_RELAYS,
|
...INDEXER_RELAYS,
|
||||||
...Router.get().FromUser().getUrls(),
|
...Router.get().FromUser().getUrls(),
|
||||||
|
|
@ -247,7 +247,7 @@ export const checkRelayAccess = async (url: string, claim = "") => {
|
||||||
await socket.auth.attemptAuth(e => signer.get()?.sign(e))
|
await socket.auth.attemptAuth(e => signer.get()?.sign(e))
|
||||||
|
|
||||||
const thunk = publishThunk({
|
const thunk = publishThunk({
|
||||||
event: createEvent(AUTH_JOIN, {tags: [["claim", claim]]}),
|
event: makeEvent(AUTH_JOIN, {tags: [["claim", claim]]}),
|
||||||
relays: [url],
|
relays: [url],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -333,7 +333,7 @@ export const makeDelete = ({event}: {event: TrustedEvent}) => {
|
||||||
tags.push(groupTag)
|
tags.push(groupTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
return createEvent(DELETE, {tags})
|
return makeEvent(DELETE, {tags})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const publishDelete = ({relays, event}: {relays: string[]; event: TrustedEvent}) =>
|
export const publishDelete = ({relays, event}: {relays: string[]; event: TrustedEvent}) =>
|
||||||
|
|
@ -351,7 +351,7 @@ export const makeReport = ({event, reason, content}: ReportParams) => {
|
||||||
["e", event.id, reason],
|
["e", event.id, reason],
|
||||||
]
|
]
|
||||||
|
|
||||||
return createEvent(REPORT, {content, tags})
|
return makeEvent(REPORT, {content, tags})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const publishReport = ({
|
export const publishReport = ({
|
||||||
|
|
@ -378,7 +378,7 @@ export const makeReaction = ({content, event, tags: paramTags = []}: ReactionPar
|
||||||
tags.push(groupTag)
|
tags.push(groupTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
return createEvent(REACTION, {content, tags})
|
return makeEvent(REACTION, {content, tags})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const publishReaction = ({relays, ...params}: ReactionParams & {relays: string[]}) =>
|
export const publishReaction = ({relays, ...params}: ReactionParams & {relays: string[]}) =>
|
||||||
|
|
@ -391,7 +391,7 @@ export type CommentParams = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeComment = ({event, content, tags = []}: CommentParams) =>
|
export const makeComment = ({event, content, tags = []}: CommentParams) =>
|
||||||
createEvent(COMMENT, {content, tags: [...tags, ...tagEventForComment(event)]})
|
makeEvent(COMMENT, {content, tags: [...tags, ...tagEventForComment(event)]})
|
||||||
|
|
||||||
export const publishComment = ({relays, ...params}: CommentParams & {relays: string[]}) =>
|
export const publishComment = ({relays, ...params}: CommentParams & {relays: string[]}) =>
|
||||||
publishThunk({event: makeComment(params), relays})
|
publishThunk({event: makeComment(params), relays})
|
||||||
|
|
@ -426,7 +426,7 @@ export const makeAlert = async ({cron, email, feed, bunker, secret, description}
|
||||||
tags.push(["nip46", secret, bunker])
|
tags.push(["nip46", secret, bunker])
|
||||||
}
|
}
|
||||||
|
|
||||||
return createEvent(ALERT, {
|
return makeEvent(ALERT, {
|
||||||
content: await signer.get().nip44.encrypt(NOTIFIER_PUBKEY, JSON.stringify(tags)),
|
content: await signer.get().nip44.encrypt(NOTIFIER_PUBKEY, JSON.stringify(tags)),
|
||||||
tags: [
|
tags: [
|
||||||
["d", randomId()],
|
["d", randomId()],
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import type {Snippet} from "svelte"
|
import type {Snippet} from "svelte"
|
||||||
import {writable} from "svelte/store"
|
import {writable} from "svelte/store"
|
||||||
import {randomId, HOUR} from "@welshman/lib"
|
import {randomId, HOUR} from "@welshman/lib"
|
||||||
import {createEvent, EVENT_TIME} from "@welshman/util"
|
import {makeEvent, EVENT_TIME} from "@welshman/util"
|
||||||
import {publishThunk} from "@welshman/app"
|
import {publishThunk} from "@welshman/app"
|
||||||
import {preventDefault} from "@lib/html"
|
import {preventDefault} from "@lib/html"
|
||||||
import {daysBetween} from "@lib/util"
|
import {daysBetween} from "@lib/util"
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const ed = await editor
|
const ed = await editor
|
||||||
const event = createEvent(EVENT_TIME, {
|
const event = makeEvent(EVENT_TIME, {
|
||||||
content: ed.getText({blockSeparator: "\n"}).trim(),
|
content: ed.getText({blockSeparator: "\n"}).trim(),
|
||||||
tags: [
|
tags: [
|
||||||
["d", initialValues?.d || randomId()],
|
["d", initialValues?.d || randomId()],
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
import type {TrustedEvent, EventTemplate, EventContent} from "@welshman/util"
|
import type {TrustedEvent, EventTemplate, EventContent} from "@welshman/util"
|
||||||
import {parse, isLink} from "@welshman/content"
|
import {parse, isLink} from "@welshman/content"
|
||||||
import {
|
import {
|
||||||
createEvent,
|
makeEvent,
|
||||||
tagsFromIMeta,
|
tagsFromIMeta,
|
||||||
getTags,
|
getTags,
|
||||||
DIRECT_MESSAGE,
|
DIRECT_MESSAGE,
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
content = content.trim()
|
content = content.trim()
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
templates.push(createEvent(kind, {content, tags: [...tags, ...ptags]}))
|
templates.push(makeEvent(kind, {content, tags: [...tags, ...ptags]}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {chunk, sleep, uniq} from "@welshman/lib"
|
import {chunk, sleep, uniq} from "@welshman/lib"
|
||||||
import {
|
import {
|
||||||
createEvent,
|
makeEvent,
|
||||||
createProfile,
|
createProfile,
|
||||||
PROFILE,
|
PROFILE,
|
||||||
DELETE,
|
DELETE,
|
||||||
|
|
@ -36,8 +36,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunks = chunk(500, repository.query([{authors: [$pubkey!]}]))
|
const chunks = chunk(500, repository.query([{authors: [$pubkey!]}]))
|
||||||
const profileEvent = createEvent(PROFILE, createProfile({name: "[deleted]"}))
|
const profileEvent = makeEvent(PROFILE, createProfile({name: "[deleted]"}))
|
||||||
const vanishEvent = createEvent(62, {tags: [["relay", "ALL_RELAYS"]]})
|
const vanishEvent = makeEvent(62, {tags: [["relay", "ALL_RELAYS"]]})
|
||||||
const denominator = chunks.length + 2
|
const denominator = chunks.length + 2
|
||||||
const relays = uniq([
|
const relays = uniq([
|
||||||
...INDEXER_RELAYS,
|
...INDEXER_RELAYS,
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await publishThunk({relays, event: createEvent(DELETE, {tags})})
|
await publishThunk({relays, event: makeEvent(DELETE, {tags})})
|
||||||
|
|
||||||
await incrementProgress()
|
await incrementProgress()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import type {Profile} from "@welshman/util"
|
import type {Profile} from "@welshman/util"
|
||||||
import {
|
import {
|
||||||
getTag,
|
getTag,
|
||||||
createEvent,
|
makeEvent,
|
||||||
makeProfile,
|
makeProfile,
|
||||||
editProfile,
|
editProfile,
|
||||||
createProfile,
|
createProfile,
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
template.tags = uniqTags([...template.tags, PROTECTED])
|
template.tags = uniqTags([...template.tags, PROTECTED])
|
||||||
}
|
}
|
||||||
|
|
||||||
const event = createEvent(template.kind, template)
|
const event = makeEvent(template.kind, template)
|
||||||
|
|
||||||
publishThunk({event, relays})
|
publishThunk({event, relays})
|
||||||
pushToast({message: "Your profile has been updated!"})
|
pushToast({message: "Your profile has been updated!"})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Profile} from "@welshman/util"
|
import type {Profile} from "@welshman/util"
|
||||||
import {PROFILE, createProfile, makeProfile, createEvent} from "@welshman/util"
|
import {PROFILE, createProfile, makeProfile, makeEvent} from "@welshman/util"
|
||||||
import {loginWithNip01, publishThunk} from "@welshman/app"
|
import {loginWithNip01, publishThunk} from "@welshman/app"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const onsubmit = ({profile, shouldBroadcast}: {profile: Profile; shouldBroadcast: boolean}) => {
|
const onsubmit = ({profile, shouldBroadcast}: {profile: Profile; shouldBroadcast: boolean}) => {
|
||||||
const event = createEvent(PROFILE, createProfile(profile))
|
const event = makeEvent(PROFILE, createProfile(profile))
|
||||||
const relays = shouldBroadcast ? INDEXER_RELAYS : []
|
const relays = shouldBroadcast ? INDEXER_RELAYS : []
|
||||||
|
|
||||||
loginWithNip01(secret)
|
loginWithNip01(secret)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {writable} from "svelte/store"
|
import {writable} from "svelte/store"
|
||||||
import {createEvent, THREAD} from "@welshman/util"
|
import {makeEvent, THREAD} from "@welshman/util"
|
||||||
import {publishThunk} from "@welshman/app"
|
import {publishThunk} from "@welshman/app"
|
||||||
import {isMobile, preventDefault} from "@lib/html"
|
import {isMobile, preventDefault} from "@lib/html"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
event: createEvent(THREAD, {content, tags}),
|
event: makeEvent(THREAD, {content, tags}),
|
||||||
})
|
})
|
||||||
|
|
||||||
history.back()
|
history.back()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import {
|
import {
|
||||||
getListTags,
|
getListTags,
|
||||||
tagger,
|
tagger,
|
||||||
createEvent,
|
makeEvent,
|
||||||
getPubkeyTagValues,
|
getPubkeyTagValues,
|
||||||
getTagValues,
|
getTagValues,
|
||||||
MUTES,
|
MUTES,
|
||||||
|
|
@ -38,17 +38,17 @@
|
||||||
const relays = Router.get().FromUser().getUrls()
|
const relays = Router.get().FromUser().getUrls()
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
event: createEvent(SETTINGS, {content}),
|
event: makeEvent(SETTINGS, {content}),
|
||||||
relays,
|
relays,
|
||||||
})
|
})
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
event: createEvent(MUTES, {tags: mutedPubkeys.map(tagPubkey)}),
|
event: makeEvent(MUTES, {tags: mutedPubkeys.map(tagPubkey)}),
|
||||||
relays,
|
relays,
|
||||||
})
|
})
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
event: createEvent(BLOSSOM_SERVERS, {tags: blossomServers.map(tagger("server"))}),
|
event: makeEvent(BLOSSOM_SERVERS, {tags: blossomServers.map(tagger("server"))}),
|
||||||
relays,
|
relays,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
import {request} from "@welshman/net"
|
import {request} from "@welshman/net"
|
||||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||||
import {
|
import {
|
||||||
createEvent,
|
makeEvent,
|
||||||
MESSAGE,
|
MESSAGE,
|
||||||
DELETE,
|
DELETE,
|
||||||
REACTION,
|
REACTION,
|
||||||
|
|
@ -123,7 +123,7 @@
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
event: createEvent(MESSAGE, template),
|
event: makeEvent(MESSAGE, template),
|
||||||
delay: $userSettingValues.send_delay,
|
delay: $userSettingValues.send_delay,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
const url = decodeRelay($page.params.relay)
|
const url = decodeRelay($page.params.relay)
|
||||||
|
|
||||||
const createEvent = () => pushModal(CalendarEventCreate, {url})
|
const makeEvent = () => pushModal(CalendarEventCreate, {url})
|
||||||
|
|
||||||
const getStart = (event: TrustedEvent) => parseInt(getTagValue("start", event.tags) || "")
|
const getStart = (event: TrustedEvent) => parseInt(getTagValue("start", event.tags) || "")
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<div class="row-2">
|
<div class="row-2">
|
||||||
<Button class="btn btn-primary btn-sm" onclick={createEvent}>
|
<Button class="btn btn-primary btn-sm" onclick={makeEvent}>
|
||||||
<Icon icon="calendar-add" />
|
<Icon icon="calendar-add" />
|
||||||
Create an Event
|
Create an Event
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
import type {Readable} from "svelte/store"
|
import type {Readable} from "svelte/store"
|
||||||
import {now, formatTimestampAsDate} from "@welshman/lib"
|
import {now, formatTimestampAsDate} from "@welshman/lib"
|
||||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||||
import {createEvent, MESSAGE, DELETE, REACTION} from "@welshman/util"
|
import {makeEvent, MESSAGE, DELETE, REACTION} from "@welshman/util"
|
||||||
import {pubkey, publishThunk} from "@welshman/app"
|
import {pubkey, publishThunk} from "@welshman/app"
|
||||||
import {slide, fade, fly} from "@lib/transition"
|
import {slide, fade, fly} from "@lib/transition"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
event: createEvent(MESSAGE, template),
|
event: makeEvent(MESSAGE, template),
|
||||||
delay: $userSettingValues.send_delay,
|
delay: $userSettingValues.send_delay,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue