kopia lustrzana https://git.sr.ht/~tsileo/microblog.pub
				
				
				
			Tweak the attachment handling for Hubzilla support
							rodzic
							
								
									4910729b2c
								
							
						
					
					
						commit
						cf46ddcb60
					
				
							
								
								
									
										7
									
								
								tasks.py
								
								
								
								
							
							
						
						
									
										7
									
								
								tasks.py
								
								
								
								
							| 
						 | 
				
			
			@ -48,9 +48,9 @@ def process_new_activity(self, iri: str) -> None:
 | 
			
		|||
 | 
			
		||||
        tag_stream = False
 | 
			
		||||
        if activity.has_type(ap.ActivityType.ANNOUNCE):
 | 
			
		||||
            tag_stream = True
 | 
			
		||||
            try:
 | 
			
		||||
                activity.get_object()
 | 
			
		||||
                tag_stream = True
 | 
			
		||||
            except NotAnActivityError:
 | 
			
		||||
                # Most likely on OStatus notice
 | 
			
		||||
                tag_stream = False
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +235,10 @@ def cache_attachments(self, iri: str) -> None:
 | 
			
		|||
 | 
			
		||||
        if activity.has_type(ap.ActivityType.CREATE):
 | 
			
		||||
            for attachment in activity.get_object()._data.get("attachment", []):
 | 
			
		||||
                if attachment.get("mediaType", "").startswith("image/"):
 | 
			
		||||
                if (
 | 
			
		||||
                    attachment.get("mediaType", "").startswith("image/")
 | 
			
		||||
                    or attachment.get("type") == ap.ActivityType.IMAGE.value
 | 
			
		||||
                ):
 | 
			
		||||
                    MEDIA_CACHE.cache(attachment["url"], Kind.ATTACHMENT)
 | 
			
		||||
 | 
			
		||||
        log.info(f"attachments cached for {iri}")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,7 @@
 | 
			
		|||
	<ul>
 | 
			
		||||
	{% endif %}
 | 
			
		||||
	{% for a in obj.attachment %}
 | 
			
		||||
	{% if a.mediaType.startswith("image/") %}
 | 
			
		||||
    {% if (a.mediaType and a.mediaType.startswith("image/")) or (a.type and a.type == 'Image') %}
 | 
			
		||||
    <a href="{{ a.url | get_attachment_url(None) }}"><img src="{{a.url | get_attachment_url(720) }}" class="img-attachment"></a>
 | 
			
		||||
	{% else %}
 | 
			
		||||
	<li><a href="{{a.url }}" class="l">{% if a.filename %}{{ a.filename }}{% else %}{{ a.url }}{% endif %}</a></li>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue