notification types and topic id

This commit is contained in:
Mothana 2026-02-04 22:30:24 +04:00
parent 6aa90d63ba
commit c146d46c59
12 changed files with 211 additions and 9 deletions

View file

@ -1670,6 +1670,14 @@ The nostr server will send back a message response, and inside the body there wi
### ProvidersDisruption
- __disruptions__: ARRAY of: _[ProviderDisruption](#ProviderDisruption)_
### PushNotificationEnvelope
- __app_npub_hex__: _string_
- __encrypted_payload__: _string_
- __topic_id__: _string_
### PushNotificationPayload
- __data__: _[PushNotificationPayload_data](#PushNotificationPayload_data)_
### RefundAdminInvoiceSwapRequest
- __sat_per_v_byte__: _number_
- __swap_operation_id__: _string_
@ -1797,6 +1805,7 @@ The nostr server will send back a message response, and inside the body there wi
- __nmanage__: _string_
- __noffer__: _string_
- __service_fee_bps__: _number_
- __topic_id__: _string_
- __userId__: _string_
- __user_identifier__: _string_

View file

@ -647,6 +647,14 @@ type ProviderDisruption struct {
type ProvidersDisruption struct {
Disruptions []ProviderDisruption `json:"disruptions"`
}
type PushNotificationEnvelope struct {
App_npub_hex string `json:"app_npub_hex"`
Encrypted_payload string `json:"encrypted_payload"`
Topic_id string `json:"topic_id"`
}
type PushNotificationPayload struct {
Data *PushNotificationPayload_data `json:"data"`
}
type RefundAdminInvoiceSwapRequest struct {
Sat_per_v_byte int64 `json:"sat_per_v_byte"`
Swap_operation_id string `json:"swap_operation_id"`
@ -774,6 +782,7 @@ type UserInfo struct {
Nmanage string `json:"nmanage"`
Noffer string `json:"noffer"`
Service_fee_bps int64 `json:"service_fee_bps"`
Topic_id string `json:"topic_id"`
Userid string `json:"userId"`
User_identifier string `json:"user_identifier"`
}
@ -872,6 +881,18 @@ type NPubLinking_state struct {
Linking_token *string `json:"linking_token"`
Unlinked *Empty `json:"unlinked"`
}
type PushNotificationPayload_data_type string
const (
RECEIVED_OPERATION PushNotificationPayload_data_type = "received_operation"
SENT_OPERATION PushNotificationPayload_data_type = "sent_operation"
)
type PushNotificationPayload_data struct {
Type PushNotificationPayload_data_type `json:"type"`
Received_operation *UserOperation `json:"received_operation"`
Sent_operation *UserOperation `json:"sent_operation"`
}
type UpdateChannelPolicyRequest_update_type string
const (

View file

@ -3843,6 +3843,53 @@ export const ProvidersDisruptionValidate = (o?: ProvidersDisruption, opts: Provi
return null
}
export type PushNotificationEnvelope = {
app_npub_hex: string
encrypted_payload: string
topic_id: string
}
export const PushNotificationEnvelopeOptionalFields: [] = []
export type PushNotificationEnvelopeOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
app_npub_hex_CustomCheck?: (v: string) => boolean
encrypted_payload_CustomCheck?: (v: string) => boolean
topic_id_CustomCheck?: (v: string) => boolean
}
export const PushNotificationEnvelopeValidate = (o?: PushNotificationEnvelope, opts: PushNotificationEnvelopeOptions = {}, path: string = 'PushNotificationEnvelope::root.'): Error | null => {
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
if (typeof o.app_npub_hex !== 'string') return new Error(`${path}.app_npub_hex: is not a string`)
if (opts.app_npub_hex_CustomCheck && !opts.app_npub_hex_CustomCheck(o.app_npub_hex)) return new Error(`${path}.app_npub_hex: custom check failed`)
if (typeof o.encrypted_payload !== 'string') return new Error(`${path}.encrypted_payload: is not a string`)
if (opts.encrypted_payload_CustomCheck && !opts.encrypted_payload_CustomCheck(o.encrypted_payload)) return new Error(`${path}.encrypted_payload: custom check failed`)
if (typeof o.topic_id !== 'string') return new Error(`${path}.topic_id: is not a string`)
if (opts.topic_id_CustomCheck && !opts.topic_id_CustomCheck(o.topic_id)) return new Error(`${path}.topic_id: custom check failed`)
return null
}
export type PushNotificationPayload = {
data: PushNotificationPayload_data
}
export const PushNotificationPayloadOptionalFields: [] = []
export type PushNotificationPayloadOptions = OptionsBaseMessage & {
checkOptionalsAreSet?: []
data_Options?: PushNotificationPayload_dataOptions
}
export const PushNotificationPayloadValidate = (o?: PushNotificationPayload, opts: PushNotificationPayloadOptions = {}, path: string = 'PushNotificationPayload::root.'): Error | null => {
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
const dataErr = PushNotificationPayload_dataValidate(o.data, opts.data_Options, `${path}.data`)
if (dataErr !== null) return dataErr
return null
}
export type RefundAdminInvoiceSwapRequest = {
sat_per_v_byte: number
swap_operation_id: string
@ -4539,6 +4586,7 @@ export type UserInfo = {
nmanage: string
noffer: string
service_fee_bps: number
topic_id: string
userId: string
user_identifier: string
}
@ -4555,6 +4603,7 @@ export type UserInfoOptions = OptionsBaseMessage & {
nmanage_CustomCheck?: (v: string) => boolean
noffer_CustomCheck?: (v: string) => boolean
service_fee_bps_CustomCheck?: (v: number) => boolean
topic_id_CustomCheck?: (v: string) => boolean
userId_CustomCheck?: (v: string) => boolean
user_identifier_CustomCheck?: (v: string) => boolean
}
@ -4592,6 +4641,9 @@ export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path:
if (typeof o.service_fee_bps !== 'number') return new Error(`${path}.service_fee_bps: is not a number`)
if (opts.service_fee_bps_CustomCheck && !opts.service_fee_bps_CustomCheck(o.service_fee_bps)) return new Error(`${path}.service_fee_bps: custom check failed`)
if (typeof o.topic_id !== 'string') return new Error(`${path}.topic_id: is not a string`)
if (opts.topic_id_CustomCheck && !opts.topic_id_CustomCheck(o.topic_id)) return new Error(`${path}.topic_id: custom check failed`)
if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`)
if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`)
@ -5009,6 +5061,43 @@ export const NPubLinking_stateValidate = (o?: NPubLinking_state, opts:NPubLinkin
if (unlinkedErr !== null) return unlinkedErr
break
default:
return new Error(path + ': unknown type '+ stringType)
}
return null
}
export enum PushNotificationPayload_data_type {
RECEIVED_OPERATION = 'received_operation',
SENT_OPERATION = 'sent_operation',
}
export const enumCheckPushNotificationPayload_data_type = (e?: PushNotificationPayload_data_type): boolean => {
for (const v in PushNotificationPayload_data_type) if (e === v) return true
return false
}
export type PushNotificationPayload_data =
{type:PushNotificationPayload_data_type.RECEIVED_OPERATION, received_operation:UserOperation}|
{type:PushNotificationPayload_data_type.SENT_OPERATION, sent_operation:UserOperation}
export type PushNotificationPayload_dataOptions = {
received_operation_Options?: UserOperationOptions
sent_operation_Options?: UserOperationOptions
}
export const PushNotificationPayload_dataValidate = (o?: PushNotificationPayload_data, opts:PushNotificationPayload_dataOptions = {}, path: string = 'PushNotificationPayload_data::root.'): Error | null => {
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
const stringType: string = o.type
switch (o.type) {
case PushNotificationPayload_data_type.RECEIVED_OPERATION:
const received_operationErr = UserOperationValidate(o.received_operation, opts.received_operation_Options, `${path}.received_operation`)
if (received_operationErr !== null) return received_operationErr
break
case PushNotificationPayload_data_type.SENT_OPERATION:
const sent_operationErr = UserOperationValidate(o.sent_operation, opts.sent_operation_Options, `${path}.sent_operation`)
if (sent_operationErr !== null) return sent_operationErr
break
default:
return new Error(path + ': unknown type '+ stringType)