Browse Source

Sync AccountContacts within AccountPolicy also

pull/52/head
Kristijan Mitrovic 4 years ago
parent
commit
ec5d1ef5cd
2 changed files with 24 additions and 3 deletions
  1. +1
    -0
      bubble-server/src/main/java/bubble/notify/NotificationHandler_sync_account.java
  2. +23
    -3
      bubble-server/src/main/java/bubble/service/account/SyncAccountNotification.java

+ 1
- 0
bubble-server/src/main/java/bubble/notify/NotificationHandler_sync_account.java View File

@@ -62,6 +62,7 @@ public class NotificationHandler_sync_account extends ReceivedNotificationHandle
return;
}
localPolicy.update(incomingPolicy);
localPolicy.setAccountContactsJson(incomingPolicy.getAccountContactsJson());
localPolicy.setSkipSync(configuration.getThisNetwork().getInstallType() == AnsibleInstallType.node);
accountPolicyDAO.update(localPolicy);
}


+ 23
- 3
bubble-server/src/main/java/bubble/service/account/SyncAccountNotification.java View File

@@ -5,15 +5,35 @@
package bubble.service.account;

import bubble.model.account.AccountPolicy;
import lombok.AllArgsConstructor;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.experimental.Accessors;

@AllArgsConstructor @NoArgsConstructor @Accessors(chain=true)
import static org.cobbzilla.util.reflect.ReflectionUtil.copy;

@NoArgsConstructor @Accessors(chain=true)
public class SyncAccountNotification {
@Getter @Setter private String accountUuid;
@Getter @Setter private String updatedHashedPassword;
@Getter @Setter private AccountPolicy updatedPolicy;
@Getter @Setter private AccountPolicyIncludingJSONContacts updatedPolicy;

public SyncAccountNotification(String accountUuid, String updatedHashedPassword, AccountPolicy updatedPolicy) {
this.accountUuid = accountUuid;
this.updatedHashedPassword = updatedHashedPassword;
if (updatedPolicy != null) {
this.updatedPolicy = new AccountPolicyIncludingJSONContacts(updatedPolicy);
}
}

@NoArgsConstructor
public class AccountPolicyIncludingJSONContacts extends AccountPolicy {
public AccountPolicyIncludingJSONContacts(@NonNull final AccountPolicy policy) { copy(this, policy); }

@Override @JsonIgnore(false) @JsonProperty
public String getAccountContactsJson() { return super.getAccountContactsJson(); }
}
}

Loading…
Cancel
Save