diff --git a/boards/models/post/sync.py b/boards/models/post/sync.py --- a/boards/models/post/sync.py +++ b/boards/models/post/sync.py @@ -1,4 +1,6 @@ import xml.etree.ElementTree as et + +from boards.utils import get_file_mimetype from django.db import transaction from boards.models import KeyPair, GlobalId, Signature, Post, Tag @@ -73,6 +75,21 @@ class SyncManager: pub_time = et.SubElement(content_tag, TAG_PUB_TIME) pub_time.text = str(post.get_pub_time_str()) + images = post.images.all() + attachments = post.attachments.all() + if len(images) > 0 or len(attachments) > 0: + attachments_tag = et.SubElement(content_tag, TAG_ATTACHMENTS) + for image in images: + mimetype = get_file_mimetype(image.image.file) + attachment = et.SubElement(attachments_tag, TAG_ATTACHMENT) + attachment.set(ATTR_MIMETYPE, mimetype) + attachment.text = image.hash + for file in attachments: + mimetype = get_file_mimetype(file.file.file) + attachment = et.SubElement(attachments_tag, TAG_ATTACHMENT) + attachment.set(ATTR_MIMETYPE, mimetype) + attachment.text = file.hash + signatures_tag = et.SubElement(model, TAG_SIGNATURES) post_signatures = post.global_id.signature_set.all() if post_signatures: