mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
expose attachments param
This commit is contained in:
1 parent
69252a7526
commit
50ed58730c
1 file changed
+16
-6
@@ -124,7 +124,12 @@ interface DMContextType {
|
|||||||
lastSync: LastSyncData;
|
lastSync: LastSyncData;
|
||||||
subscriptions: SubscriptionStatus;
|
subscriptions: SubscriptionStatus;
|
||||||
conversations: ConversationSummary[];
|
conversations: ConversationSummary[];
|
||||||
sendMessage: (params: { recipientPubkey: string; content: string; protocol?: MessageProtocol }) => Promise<void>;
|
sendMessage: (params: {
|
||||||
|
recipientPubkey: string;
|
||||||
|
content: string;
|
||||||
|
protocol?: MessageProtocol;
|
||||||
|
attachments?: FileAttachment[];
|
||||||
|
}) => Promise<void>;
|
||||||
protocolMode: ProtocolMode;
|
protocolMode: ProtocolMode;
|
||||||
scanProgress: ScanProgressState;
|
scanProgress: ScanProgressState;
|
||||||
clearCacheAndRefetch: () => Promise<void>;
|
clearCacheAndRefetch: () => Promise<void>;
|
||||||
@@ -203,7 +208,7 @@ interface DMProviderProps {
|
|||||||
// Message Sending Types and Helpers (Internal)
|
// Message Sending Types and Helpers (Internal)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
interface FileAttachment {
|
export interface FileAttachment {
|
||||||
url: string;
|
url: string;
|
||||||
mimeType: string;
|
mimeType: string;
|
||||||
size: number;
|
size: number;
|
||||||
@@ -1469,10 +1474,15 @@ export function DMProvider({ children, config }: DMProviderProps) {
|
|||||||
}, [enabled, messages, shouldSaveImmediately, writeAllMessagesToStore, triggerDebouncedWrite]);
|
}, [enabled, messages, shouldSaveImmediately, writeAllMessagesToStore, triggerDebouncedWrite]);
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
const sendMessage = useCallback(async (params: { recipientPubkey: string; content: string; protocol?: MessageProtocol }) => {
|
const sendMessage = useCallback(async (params: {
|
||||||
|
recipientPubkey: string;
|
||||||
|
content: string;
|
||||||
|
protocol?: MessageProtocol;
|
||||||
|
attachments?: FileAttachment[];
|
||||||
|
}) => {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
|
|
||||||
const { recipientPubkey, content, protocol = MESSAGE_PROTOCOL.NIP04 } = params;
|
const { recipientPubkey, content, protocol = MESSAGE_PROTOCOL.NIP04, attachments } = params;
|
||||||
if (!userPubkey) return;
|
if (!userPubkey) return;
|
||||||
|
|
||||||
const optimisticId = `optimistic-${Date.now()}-${Math.random()}`;
|
const optimisticId = `optimistic-${Date.now()}-${Math.random()}`;
|
||||||
@@ -1493,9 +1503,9 @@ export function DMProvider({ children, config }: DMProviderProps) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (protocol === MESSAGE_PROTOCOL.NIP04) {
|
if (protocol === MESSAGE_PROTOCOL.NIP04) {
|
||||||
await sendNIP4Message.mutateAsync({ recipientPubkey, content });
|
await sendNIP4Message.mutateAsync({ recipientPubkey, content, attachments });
|
||||||
} else if (protocol === MESSAGE_PROTOCOL.NIP17) {
|
} else if (protocol === MESSAGE_PROTOCOL.NIP17) {
|
||||||
await sendNIP17Message.mutateAsync({ recipientPubkey, content });
|
await sendNIP17Message.mutateAsync({ recipientPubkey, content, attachments });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[DM] Failed to send ${protocol} message:`, error);
|
console.error(`[DM] Failed to send ${protocol} message:`, error);
|
||||||
|
|||||||
Reference in new issue
Block a user