Esempio n. 1
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     struct_to_xml(element, [
         {
             "parent_type": "Post"
         },
         {
             "guid": self.guid
         },
         {
             "parent_guid": self.target_guid
         },
         {
             "author_signature": self.signature
         },
         {
             "parent_author_signature": self.parent_signature
         },
         {
             "positive": "true"
         },
         {
             "author": self.handle
         },
     ])
     return element
Esempio n. 2
0
 def to_xml(self):
     element = etree.Element(self._tag_name)
     struct_to_xml(element, [
         {
             "guid": self.guid
         },
         {
             "parent_guid": self.root_target_guid or self.target_guid
         },
         {
             "thread_parent_guid": self.target_guid
         },
         {
             "author_signature": self.signature
         },
         {
             "parent_author_signature": self.parent_signature
         },
         {
             "text": self.raw_content
         },
         {
             "author": self.handle
         },
         {
             "created_at": format_dt(self.created_at)
         },
     ])
     return element
Esempio n. 3
0
 def to_xml(self):
     element = etree.Element(self._tag_name)
     struct_to_xml(
         element,
         [
             {
                 "author": self.handle
             },
             {
                 "guid": self.guid
             },
             {
                 "created_at": format_dt(self.created_at)
             },
             {
                 "root_author": self.target_handle
             },
             {
                 "root_guid": self.target_guid
             },
             {
                 "provider_display_name": self.provider_display_name
             },
             {
                 "public": "true" if self.public else "false"
             },
             # Some of our own not in Diaspora protocol
             {
                 "text": self.raw_content
             },
             {
                 "entity_type": self.entity_type
             },
         ])
     return element
Esempio n. 4
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     properties = [
         {
             "text": self.raw_content
         },
         {
             "guid": self.guid
         },
         {
             "author": self.handle
         },
         {
             "public": "true" if self.public else "false"
         },
         {
             "created_at": format_dt(self.created_at)
         },
         {
             "provider_display_name": self.provider_display_name
         },
     ]
     if self.id and self.id.startswith("http"):
         properties.append({
             "activitypub_id": self.id,
         })
     struct_to_xml(element, properties)
     return element
Esempio n. 5
0
 def to_xml(self):
     element = etree.Element(self._tag_name)
     properties = [
         {
             "guid": self.guid
         },
         {
             "parent_guid": self.root_target_guid or self.target_guid
         },
         {
             "thread_parent_guid": self.target_guid
         },
         {
             "author_signature": self.signature
         },
         {
             "parent_author_signature": self.parent_signature
         },
         {
             "text": self.raw_content
         },
         {
             "author": self.handle
         },
         {
             "created_at": format_dt(self.created_at)
         },
     ]
     if self.id and self.id.startswith("http"):
         properties.append({
             "activitypub_id": self.id,
         })
     struct_to_xml(element, properties)
     return element
Esempio n. 6
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     struct_to_xml(element, [
         {"sender_handle": self.handle},
         {"recipient_handle": self.target_handle},
     ])
     return element
Esempio n. 7
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element("request")
     struct_to_xml(element, [
         {"sender_handle": self.handle},
         {"recipient_handle": self.target_handle},
     ])
     return element
Esempio n. 8
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     struct_to_xml(element, [
         {"author": self.handle},
         {"target_guid": self.target_guid},
         {"target_type": DiasporaRetraction.entity_type_to_remote(self.entity_type)},
     ])
     return element
Esempio n. 9
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element("retraction")
     struct_to_xml(element, [
         {"author": self.handle},
         {"target_guid": self.target_guid},
         {"target_type": DiasporaRetraction.entity_type_to_remote(self.entity_type)},
     ])
     return element
Esempio n. 10
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     struct_to_xml(element, [
         {"author": self.handle},
         {"recipient": self.target_handle},
         {"following": "true" if self.following else "false"},
         {"sharing": "true" if self.following else "false"},
     ])
     return element
Esempio n. 11
0
 def to_xml(self):
     element = etree.Element("comment")
     struct_to_xml(element, [
         {'guid': self.guid},
         {'parent_guid': self.target_guid},
         {'author_signature': self.author_signature},
         {'text': self.raw_content},
         {'diaspora_handle': self.handle},
     ])
     return element
Esempio n. 12
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element("status_message")
     struct_to_xml(element, [
         {'raw_message': self.raw_content},
         {'guid': self.guid},
         {'diaspora_handle': self.handle},
         {'public': 'true' if self.public else 'false'},
         {'created_at': format_dt(self.created_at)}
     ])
     return element
Esempio n. 13
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     struct_to_xml(element, [
         {"text": self.raw_content},
         {"guid": self.guid},
         {"author": self.handle},
         {"public": "true" if self.public else "false"},
         {"created_at": format_dt(self.created_at)},
         {"provider_display_name": self.provider_display_name},
     ])
     return element
Esempio n. 14
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element("like")
     struct_to_xml(element, [
         {"target_type": "Post"},
         {'guid': self.guid},
         {'parent_guid': self.target_guid},
         {'author_signature': self.author_signature},
         {"positive": "true"},
         {'diaspora_handle': self.handle},
     ])
     return element
Esempio n. 15
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     properties = [
         {
             "author": self.handle
         },
         {
             "first_name": self.name
         },
         {
             "last_name": ""
         },  # We only have one field - splitting it would be artificial
         {
             "image_url": self.image_urls["large"]
         },
         {
             "image_url_small": self.image_urls["small"]
         },
         {
             "image_url_medium": self.image_urls["medium"]
         },
         {
             "gender": self.gender
         },
         {
             "bio": self.raw_content
         },
         {
             "location": self.location
         },
         {
             "searchable": "true" if self.public else "false"
         },
         {
             "nsfw": "true" if self.nsfw else "false"
         },
         {
             "tag_string": " ".join(["#%s" % tag for tag in self.tag_list])
         },
     ]
     if self.id and self.id.startswith("http"):
         properties.append({
             "activitypub_id": self.id,
         })
     struct_to_xml(element, properties)
     return element
Esempio n. 16
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element(self._tag_name)
     struct_to_xml(
         element,
         [
             {
                 "author": self.handle
             },
             {
                 "first_name": self.name
             },
             {
                 "last_name": ""
             },  # Not used in Diaspora modern profiles
             {
                 "image_url": self.image_urls["large"]
             },
             {
                 "image_url_small": self.image_urls["small"]
             },
             {
                 "image_url_medium": self.image_urls["medium"]
             },
             {
                 "gender": self.gender
             },
             {
                 "bio": self.raw_content
             },
             {
                 "location": self.location
             },
             {
                 "searchable": "true" if self.public else "false"
             },
             {
                 "nsfw": "true" if self.nsfw else "false"
             },
             {
                 "tag_string": " ".join(
                     ["#%s" % tag for tag in self.tag_list])
             },
         ])
     return element
Esempio n. 17
0
 def to_xml(self):
     """Convert to XML message."""
     element = etree.Element("profile")
     struct_to_xml(element, [
         {"diaspora_handle": self.handle},
         {"first_name": self.name},
         {"last_name": ""},  # Not used in Diaspora modern profiles
         {"image_url": self.image_urls["large"]},
         {"image_url_small": self.image_urls["small"]},
         {"image_url_medium": self.image_urls["medium"]},
         {"gender": self.gender},
         {"bio": self.raw_content},
         {"location": self.location},
         {"searchable": "true" if self.public else "false"},
         {"nsfw": "true" if self.nsfw else "false"},
         {"tag_string": " ".join(["#%s" % tag for tag in self.tag_list])},
     ])
     return element