mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
just format
This commit is contained in:
39
nip28.ts
39
nip28.ts
@@ -1,4 +1,4 @@
|
||||
import {Event, finishEvent, Kind} from './event.ts'
|
||||
import { Event, finishEvent, Kind } from './event.ts'
|
||||
|
||||
export interface ChannelMetadata {
|
||||
name: string
|
||||
@@ -32,13 +32,13 @@ export interface ChannelMessageEventTemplate {
|
||||
|
||||
export interface ChannelHideMessageEventTemplate {
|
||||
channel_message_event_id: string
|
||||
content: string | {reason: string}
|
||||
content: string | { reason: string }
|
||||
created_at: number
|
||||
tags?: string[][]
|
||||
}
|
||||
|
||||
export interface ChannelMuteUserEventTemplate {
|
||||
content: string | {reason: string}
|
||||
content: string | { reason: string }
|
||||
created_at: number
|
||||
pubkey_to_mute: string
|
||||
tags?: string[][]
|
||||
@@ -46,7 +46,7 @@ export interface ChannelMuteUserEventTemplate {
|
||||
|
||||
export const channelCreateEvent = (
|
||||
t: ChannelCreateEventTemplate,
|
||||
privateKey: string
|
||||
privateKey: string,
|
||||
): Event<Kind.ChannelCreation> | undefined => {
|
||||
let content: string
|
||||
if (typeof t.content === 'object') {
|
||||
@@ -62,15 +62,15 @@ export const channelCreateEvent = (
|
||||
kind: Kind.ChannelCreation,
|
||||
tags: [...(t.tags ?? [])],
|
||||
content: content,
|
||||
created_at: t.created_at
|
||||
created_at: t.created_at,
|
||||
},
|
||||
privateKey
|
||||
privateKey,
|
||||
)
|
||||
}
|
||||
|
||||
export const channelMetadataEvent = (
|
||||
t: ChannelMetadataEventTemplate,
|
||||
privateKey: string
|
||||
privateKey: string,
|
||||
): Event<Kind.ChannelMetadata> | undefined => {
|
||||
let content: string
|
||||
if (typeof t.content === 'object') {
|
||||
@@ -86,16 +86,13 @@ export const channelMetadataEvent = (
|
||||
kind: Kind.ChannelMetadata,
|
||||
tags: [['e', t.channel_create_event_id], ...(t.tags ?? [])],
|
||||
content: content,
|
||||
created_at: t.created_at
|
||||
created_at: t.created_at,
|
||||
},
|
||||
privateKey
|
||||
privateKey,
|
||||
)
|
||||
}
|
||||
|
||||
export const channelMessageEvent = (
|
||||
t: ChannelMessageEventTemplate,
|
||||
privateKey: string
|
||||
): Event<Kind.ChannelMessage> => {
|
||||
export const channelMessageEvent = (t: ChannelMessageEventTemplate, privateKey: string): Event<Kind.ChannelMessage> => {
|
||||
const tags = [['e', t.channel_create_event_id, t.relay_url, 'root']]
|
||||
|
||||
if (t.reply_to_channel_message_event_id) {
|
||||
@@ -107,16 +104,16 @@ export const channelMessageEvent = (
|
||||
kind: Kind.ChannelMessage,
|
||||
tags: [...tags, ...(t.tags ?? [])],
|
||||
content: t.content,
|
||||
created_at: t.created_at
|
||||
created_at: t.created_at,
|
||||
},
|
||||
privateKey
|
||||
privateKey,
|
||||
)
|
||||
}
|
||||
|
||||
/* "e" tag should be the kind 42 event to hide */
|
||||
export const channelHideMessageEvent = (
|
||||
t: ChannelHideMessageEventTemplate,
|
||||
privateKey: string
|
||||
privateKey: string,
|
||||
): Event<Kind.ChannelHideMessage> | undefined => {
|
||||
let content: string
|
||||
if (typeof t.content === 'object') {
|
||||
@@ -132,15 +129,15 @@ export const channelHideMessageEvent = (
|
||||
kind: Kind.ChannelHideMessage,
|
||||
tags: [['e', t.channel_message_event_id], ...(t.tags ?? [])],
|
||||
content: content,
|
||||
created_at: t.created_at
|
||||
created_at: t.created_at,
|
||||
},
|
||||
privateKey
|
||||
privateKey,
|
||||
)
|
||||
}
|
||||
|
||||
export const channelMuteUserEvent = (
|
||||
t: ChannelMuteUserEventTemplate,
|
||||
privateKey: string
|
||||
privateKey: string,
|
||||
): Event<Kind.ChannelMuteUser> | undefined => {
|
||||
let content: string
|
||||
if (typeof t.content === 'object') {
|
||||
@@ -156,8 +153,8 @@ export const channelMuteUserEvent = (
|
||||
kind: Kind.ChannelMuteUser,
|
||||
tags: [['p', t.pubkey_to_mute], ...(t.tags ?? [])],
|
||||
content: content,
|
||||
created_at: t.created_at
|
||||
created_at: t.created_at,
|
||||
},
|
||||
privateKey
|
||||
privateKey,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user