(cls, app, id=None, type=None)
同步所有永久素材
同步所有永久素材
同步所有永久素材
def sync(cls, app, id=None, type=None):
        """同步所有永久素材"""
        if id:
            if type not in (cls.Type.NEWS, cls.Type.VIDEO):
                raise NotImplementedError()
            data = app.client.material.get_raw(id)
            return app.materials.create_material(
                type=type, media_id=id, **data)
        else:
            updated = []
            for type, _ in enum2choices(cls.Type):
                with transaction.atomic():
                    updates = cls.sync_type(app, type)
                    updated.extend(updates)
            return updated
def sync ( cls , app , id = None , type = None ) : if id : if type not in ( cls . Type . NEWS , cls . Type . VIDEO ) : raise NotImplementedError ( ) data = app . client . material . get_raw ( id ) return app . materials . create_material ( type = type , media_id = id , * * data ) else : updated = [ ] for type , _ in enum2choices ( cls . Type ) : with transaction . atomic ( ) : updates = cls . sync_type ( app , type ) updated . extend ( updates ) return updated