forked from coracle/flotilla
rename createEvent to makeEvent
This commit is contained in:
+13
-13
@@ -19,7 +19,7 @@ import {
|
||||
GROUPS,
|
||||
COMMENT,
|
||||
isSignedEvent,
|
||||
createEvent,
|
||||
makeEvent,
|
||||
displayProfile,
|
||||
normalizeRelayUrl,
|
||||
makeList,
|
||||
@@ -129,13 +129,13 @@ export const broadcastUserData = async (relays: string[]) => {
|
||||
// NIP 29 stuff
|
||||
|
||||
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]})
|
||||
}
|
||||
|
||||
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)],
|
||||
})
|
||||
|
||||
@@ -143,13 +143,13 @@ export const editRoom = (url: string, room: string, meta: Record<string, 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]})
|
||||
}
|
||||
|
||||
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]})
|
||||
}
|
||||
@@ -207,7 +207,7 @@ export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
|
||||
}
|
||||
|
||||
return publishThunk({
|
||||
event: createEvent(list.kind, {tags}),
|
||||
event: makeEvent(list.kind, {tags}),
|
||||
relays: [
|
||||
url,
|
||||
...INDEXER_RELAYS,
|
||||
@@ -229,7 +229,7 @@ export const setInboxRelayPolicy = (url: string, enabled: boolean) => {
|
||||
}
|
||||
|
||||
return publishThunk({
|
||||
event: createEvent(list.kind, {tags}),
|
||||
event: makeEvent(list.kind, {tags}),
|
||||
relays: [
|
||||
...INDEXER_RELAYS,
|
||||
...Router.get().FromUser().getUrls(),
|
||||
@@ -247,7 +247,7 @@ export const checkRelayAccess = async (url: string, claim = "") => {
|
||||
await socket.auth.attemptAuth(e => signer.get()?.sign(e))
|
||||
|
||||
const thunk = publishThunk({
|
||||
event: createEvent(AUTH_JOIN, {tags: [["claim", claim]]}),
|
||||
event: makeEvent(AUTH_JOIN, {tags: [["claim", claim]]}),
|
||||
relays: [url],
|
||||
})
|
||||
|
||||
@@ -333,7 +333,7 @@ export const makeDelete = ({event}: {event: TrustedEvent}) => {
|
||||
tags.push(groupTag)
|
||||
}
|
||||
|
||||
return createEvent(DELETE, {tags})
|
||||
return makeEvent(DELETE, {tags})
|
||||
}
|
||||
|
||||
export const publishDelete = ({relays, event}: {relays: string[]; event: TrustedEvent}) =>
|
||||
@@ -351,7 +351,7 @@ export const makeReport = ({event, reason, content}: ReportParams) => {
|
||||
["e", event.id, reason],
|
||||
]
|
||||
|
||||
return createEvent(REPORT, {content, tags})
|
||||
return makeEvent(REPORT, {content, tags})
|
||||
}
|
||||
|
||||
export const publishReport = ({
|
||||
@@ -378,7 +378,7 @@ export const makeReaction = ({content, event, tags: paramTags = []}: ReactionPar
|
||||
tags.push(groupTag)
|
||||
}
|
||||
|
||||
return createEvent(REACTION, {content, tags})
|
||||
return makeEvent(REACTION, {content, tags})
|
||||
}
|
||||
|
||||
export const publishReaction = ({relays, ...params}: ReactionParams & {relays: string[]}) =>
|
||||
@@ -391,7 +391,7 @@ export type 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[]}) =>
|
||||
publishThunk({event: makeComment(params), relays})
|
||||
@@ -426,7 +426,7 @@ export const makeAlert = async ({cron, email, feed, bunker, secret, description}
|
||||
tags.push(["nip46", secret, bunker])
|
||||
}
|
||||
|
||||
return createEvent(ALERT, {
|
||||
return makeEvent(ALERT, {
|
||||
content: await signer.get().nip44.encrypt(NOTIFIER_PUBKEY, JSON.stringify(tags)),
|
||||
tags: [
|
||||
["d", randomId()],
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type {Snippet} from "svelte"
|
||||
import {writable} from "svelte/store"
|
||||
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 {preventDefault} from "@lib/html"
|
||||
import {daysBetween} from "@lib/util"
|
||||
@@ -63,7 +63,7 @@
|
||||
}
|
||||
|
||||
const ed = await editor
|
||||
const event = createEvent(EVENT_TIME, {
|
||||
const event = makeEvent(EVENT_TIME, {
|
||||
content: ed.getText({blockSeparator: "\n"}).trim(),
|
||||
tags: [
|
||||
["d", initialValues?.d || randomId()],
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import type {TrustedEvent, EventTemplate, EventContent} from "@welshman/util"
|
||||
import {parse, isLink} from "@welshman/content"
|
||||
import {
|
||||
createEvent,
|
||||
makeEvent,
|
||||
tagsFromIMeta,
|
||||
getTags,
|
||||
DIRECT_MESSAGE,
|
||||
@@ -97,7 +97,7 @@
|
||||
content = content.trim()
|
||||
|
||||
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">
|
||||
import {chunk, sleep, uniq} from "@welshman/lib"
|
||||
import {
|
||||
createEvent,
|
||||
makeEvent,
|
||||
createProfile,
|
||||
PROFILE,
|
||||
DELETE,
|
||||
@@ -36,8 +36,8 @@
|
||||
}
|
||||
|
||||
const chunks = chunk(500, repository.query([{authors: [$pubkey!]}]))
|
||||
const profileEvent = createEvent(PROFILE, createProfile({name: "[deleted]"}))
|
||||
const vanishEvent = createEvent(62, {tags: [["relay", "ALL_RELAYS"]]})
|
||||
const profileEvent = makeEvent(PROFILE, createProfile({name: "[deleted]"}))
|
||||
const vanishEvent = makeEvent(62, {tags: [["relay", "ALL_RELAYS"]]})
|
||||
const denominator = chunks.length + 2
|
||||
const relays = uniq([
|
||||
...INDEXER_RELAYS,
|
||||
@@ -75,7 +75,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
await publishThunk({relays, event: createEvent(DELETE, {tags})})
|
||||
await publishThunk({relays, event: makeEvent(DELETE, {tags})})
|
||||
|
||||
await incrementProgress()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type {Profile} from "@welshman/util"
|
||||
import {
|
||||
getTag,
|
||||
createEvent,
|
||||
makeEvent,
|
||||
makeProfile,
|
||||
editProfile,
|
||||
createProfile,
|
||||
@@ -33,7 +33,7 @@
|
||||
template.tags = uniqTags([...template.tags, PROTECTED])
|
||||
}
|
||||
|
||||
const event = createEvent(template.kind, template)
|
||||
const event = makeEvent(template.kind, template)
|
||||
|
||||
publishThunk({event, relays})
|
||||
pushToast({message: "Your profile has been updated!"})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
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 Button from "@lib/components/Button.svelte"
|
||||
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
|
||||
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 : []
|
||||
|
||||
loginWithNip01(secret)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {writable} from "svelte/store"
|
||||
import {createEvent, THREAD} from "@welshman/util"
|
||||
import {makeEvent, THREAD} from "@welshman/util"
|
||||
import {publishThunk} from "@welshman/app"
|
||||
import {isMobile, preventDefault} from "@lib/html"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
publishThunk({
|
||||
relays: [url],
|
||||
event: createEvent(THREAD, {content, tags}),
|
||||
event: makeEvent(THREAD, {content, tags}),
|
||||
})
|
||||
|
||||
history.back()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {
|
||||
getListTags,
|
||||
tagger,
|
||||
createEvent,
|
||||
makeEvent,
|
||||
getPubkeyTagValues,
|
||||
getTagValues,
|
||||
MUTES,
|
||||
@@ -38,17 +38,17 @@
|
||||
const relays = Router.get().FromUser().getUrls()
|
||||
|
||||
publishThunk({
|
||||
event: createEvent(SETTINGS, {content}),
|
||||
event: makeEvent(SETTINGS, {content}),
|
||||
relays,
|
||||
})
|
||||
|
||||
publishThunk({
|
||||
event: createEvent(MUTES, {tags: mutedPubkeys.map(tagPubkey)}),
|
||||
event: makeEvent(MUTES, {tags: mutedPubkeys.map(tagPubkey)}),
|
||||
relays,
|
||||
})
|
||||
|
||||
publishThunk({
|
||||
event: createEvent(BLOSSOM_SERVERS, {tags: blossomServers.map(tagger("server"))}),
|
||||
event: makeEvent(BLOSSOM_SERVERS, {tags: blossomServers.map(tagger("server"))}),
|
||||
relays,
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import {request} from "@welshman/net"
|
||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||
import {
|
||||
createEvent,
|
||||
makeEvent,
|
||||
MESSAGE,
|
||||
DELETE,
|
||||
REACTION,
|
||||
@@ -123,7 +123,7 @@
|
||||
|
||||
publishThunk({
|
||||
relays: [url],
|
||||
event: createEvent(MESSAGE, template),
|
||||
event: makeEvent(MESSAGE, template),
|
||||
delay: $userSettingValues.send_delay,
|
||||
})
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
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) || "")
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
{/snippet}
|
||||
{#snippet action()}
|
||||
<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" />
|
||||
Create an Event
|
||||
</Button>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import type {Readable} from "svelte/store"
|
||||
import {now, formatTimestampAsDate} from "@welshman/lib"
|
||||
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 {slide, fade, fly} from "@lib/transition"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
publishThunk({
|
||||
relays: [url],
|
||||
event: createEvent(MESSAGE, template),
|
||||
event: makeEvent(MESSAGE, template),
|
||||
delay: $userSettingValues.send_delay,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user