ungana

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README

commit 4832ea6bbc323415941c74f6fb725819c496fbb1
parent 7cb81b77114dcdfb66c08114050eb526971bd150
Author: Carlosokumu <carlosokumu254@gmail.com>
Date:   Thu, 25 Sep 2025 21:48:26 +0300

add method to extract ical attachments

Diffstat:
Mungana/ical/ical_helper.py | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/ungana/ical/ical_helper.py b/ungana/ical/ical_helper.py @@ -131,6 +131,28 @@ class ICalHelper: if decode: return val.decode("utf-8") return val + + + @staticmethod + def extract_ical_attachments(ev, decode: bool = True): + vals = ev.get("ATTACH") + if vals is None: + return [] + if not isinstance(vals, list): + vals = [vals] + + attachments = [] + for val in vals: + data = val.to_ical() + if decode: + data = data.decode("utf-8") + attachments.append({ + "value": data, + "fmt": val.params.get("FMTTYPE"), + "ctx": val.params.get("CTX"), + }) + return attachments +