MCPcopy Create free account
hub / github.com/block/buzz / handleEditMessage

Function handleEditMessage

desktop/src/testing/e2eBridge.ts:7139–7173  ·  view source on GitHub ↗

* Mock the `edit_message` Tauri command. Mirrors the real Rust command * (`build_message_edit`): emit a kind:40003 edit event carrying `["e", target]` * plus the new content, media (imeta) tags, and NIP-30 emoji tags. The timeline * (`formatTimelineMessages`) scans for these edit events and overl

(
  args: {
    channelId: string;
    eventId: string;
    content: string;
    mediaTags?: string[][] | null;
    emojiTags?: string[][] | null;
  },
  config: E2eConfig | undefined,
)

Source from the content-addressed store, hash-verified

7137 * path the real relay drives. `null`/empty tag args → no extra tags.
7138 */
7139async function handleEditMessage(
7140 args: {
7141 channelId: string;
7142 eventId: string;
7143 content: string;
7144 mediaTags?: string[][] | null;
7145 emojiTags?: string[][] | null;
7146 },
7147 config: E2eConfig | undefined,
7148): Promise<void> {
7149 const mediaTags = args.mediaTags ?? [];
7150 const emojiTags = args.emojiTags ?? [];
7151 const extraTags = [...mediaTags, ...emojiTags];
7152 const tags = [["h", args.channelId], ["e", args.eventId], ...extraTags];
7153 const content = args.content.trim();
7154 const identity = getIdentity(config);
7155
7156 if (!identity) {
7157 const editEvent = createMockEvent(
7158 KIND_STREAM_MESSAGE_EDIT,
7159 content,
7160 tags,
7161 getMockMemberPubkey(config),
7162 );
7163 recordMockMessage(args.channelId, editEvent);
7164 emitMockLiveEvent(args.channelId, editEvent);
7165 return;
7166 }
7167
7168 await submitSignedEvent(config, {
7169 kind: KIND_STREAM_MESSAGE_EDIT,
7170 content,
7171 tags,
7172 });
7173}
7174
7175/** Locate the channel a stored mock event lives in (reactions carry no channel arg). */
7176function findMockEventChannel(eventId: string): string | undefined {

Callers 1

handleMockCommandFunction · 0.85

Calls 6

createMockEventFunction · 0.85
getMockMemberPubkeyFunction · 0.85
recordMockMessageFunction · 0.85
emitMockLiveEventFunction · 0.85
submitSignedEventFunction · 0.85
getIdentityFunction · 0.70

Tested by

no test coverage detected