fix: 更新账号后 立即推送 (#9462)

Co-authored-by: feng <1304903146@qq.com>
pull/9465/head
fit2bot 2023-02-08 13:36:32 +08:00 committed by GitHub
parent 32afa214fd
commit d308efc63b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -153,6 +153,11 @@ class ChangeSecretManager(AccountBasePlaybookManager):
logger.error("Change secret error: ", e) logger.error("Change secret error: ", e)
def run(self, *args, **kwargs): def run(self, *args, **kwargs):
if self.secret_strategy == SecretStrategy.custom \
and not self.execution.snapshot['secret']:
print('Custom secret is empty')
return
super().run(*args, **kwargs) super().run(*args, **kwargs)
recorders = self.name_recorder_mapper.values() recorders = self.name_recorder_mapper.values()
recorders = list(recorders) recorders = list(recorders)

View File

@ -39,11 +39,22 @@ class AccountSerializerCreateValidateMixin:
attrs = super().validate(attrs) attrs = super().validate(attrs)
return self.set_secret(attrs) return self.set_secret(attrs)
@staticmethod
def push_account(instance, push_now):
if not push_now:
return
push_accounts_to_assets.delay([instance.id], [instance.asset_id])
def create(self, validated_data): def create(self, validated_data):
push_now = validated_data.pop('push_now', None) push_now = validated_data.pop('push_now', None)
instance = super().create(validated_data) instance = super().create(validated_data, push_now)
if push_now: self.push_account(instance, push_now)
push_accounts_to_assets.delay([instance.id], [instance.asset_id]) return instance
def update(self, instance, validated_data):
push_now = validated_data.pop('push_now', None)
instance = super().update(instance, validated_data)
self.push_account(instance, push_now)
return instance return instance