async def METHOD_NAME(self, payload, user, **kwargs):
    custom_template = None
    object_type = payload.get(OBJECT_TYPE_KEY)
    template_uuid = payload.get('template_uuid')
    if template_uuid:
        template_uuid = clean_name(template_uuid)
        payload['template_uuid'] = template_uuid
    if DIRECTORY_FOR_BLOCK_TEMPLATES == object_type:
        custom_template = CustomBlockTemplate.load(template_uuid=template_uuid)
        if not custom_template:
            custom_template = CustomBlockTemplate(**ignore_keys(payload, [
                'uuid',
                OBJECT_TYPE_KEY,
            ]))
            if user:
                custom_template.user = dict(
                    username=user.username,
                )
            custom_template.content = fetch_template_source(
                custom_template.block_type,
                payload.get('config', {}),
                language=custom_template.language,
            )
            custom_template.save()
            cache = await BlockActionObjectCache.initialize_cache()
            cache.update_custom_block_template(custom_template)
    elif DIRECTORY_FOR_PIPELINE_TEMPLATES == object_type:
        custom_template = CustomPipelineTemplate.load(template_uuid=template_uuid)
        if not custom_template:
            pipeline = Pipeline.get(payload.get('pipeline_uuid'))
            custom_template = CustomPipelineTemplate.create_from_pipeline(
                pipeline,
                template_uuid,
                name=payload.get('name'),
                description=payload.get('description'),
            )
            if user:
                custom_template.user = dict(
                    username=user.username,
                )
            custom_template.save()
    if custom_template:
        return self(custom_template, user, **kwargs)