def get_extended_attributes()

in src/olympia/abuse/cinder.py [0:0]


    def get_extended_attributes(self):
        data = {}
        if backup_storage_enabled():
            if self.addon.icon_type:
                icon_size = max(amo.ADDON_ICON_SIZES)
                icon_type, _ = mimetypes.guess_type(f'icon.{amo.ADDON_ICON_FORMAT}')
                icon_path = self.addon.get_icon_path(icon_size)
                if icon_type and storage.exists(icon_path):
                    filename = copy_file_to_backup_storage(icon_path, icon_type)
                    data['icon'] = {
                        'value': create_signed_url_for_file_backup(filename),
                        'mime_type': icon_type,
                    }
            previews = []
            for preview in self.addon.current_previews:
                if (
                    self.addon.type == amo.ADDON_STATICTHEME
                    and preview.position
                    != amo.THEME_PREVIEW_RENDERINGS['amo']['position']
                ):
                    # For themes, we automatically generate 2 previews with
                    # different sizes and format, we only need to expose one.
                    continue
                content_type, _ = mimetypes.guess_type(preview.thumbnail_path)
                if content_type and storage.exists(preview.thumbnail_path):
                    filename = copy_file_to_backup_storage(
                        preview.thumbnail_path, content_type
                    )
                    previews.append(
                        {
                            'value': create_signed_url_for_file_backup(filename),
                            'mime_type': content_type,
                        }
                    )
            if previews:
                data['previews'] = previews

        # Those fields are only shown on the detail page, so we only have them
        # in extended attributes to avoid sending them when we send an add-on
        # as a related entity to something else.
        data['description'] = self.get_str(self.addon.description)
        if self.addon.current_version:
            data['version'] = self.get_str(self.addon.current_version.version)
            data['release_notes'] = self.get_str(
                self.addon.current_version.release_notes
            )
        data['privacy_policy'] = self.get_str(self.addon.privacy_policy)
        # The URL/email fields can't be sent as empty strings as they would not
        # be considered valid by Cinder.
        data['homepage'] = self.get_str(self.addon.homepage) or None
        data['support_email'] = self.get_str(self.addon.support_email) or None
        data['support_url'] = self.get_str(self.addon.support_url) or None
        return data