Skip to main content

Module attachments

Module attachments 

Source
Expand description

Community message attachments (NIP-92 imeta).

Unlike NIP-17 DMs (one media item per event), a Community message event carries its caption in content plus one imeta tag per attachment — so a single message can mix text and N files. Each imeta holds the per-file AES-GCM key+nonce (the NIP-17 attachment technique: fresh random key per file), so the Blossom ciphertext is only decryptable by members who can open the event.

Functions§

attachment_from_imeta
Parse a single imeta tag into an Attachment. None if the tag isn’t an imeta or is missing the required url / decryption fields. download_dir computes the (not-yet-downloaded) local target path, mirroring the DM file-attachment path.
attachment_to_imeta
Encode an Attachment as a NIP-92 imeta tag with Vector’s encryption fields. Entries are space-delimited key value strings (NIP-92 form); a value may contain spaces (e.g. a filename) since only the first space delimits key from value.
attachments_from_tags
Parse every imeta tag on an event into attachments, order preserved. Capped: a max-size event can carry ~1700 imeta tags, each becoming a persisted + in-STATE Attachment — bound the per-message amplification.