mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 19:35:10 +01:00
Added uuid to identities
This commit is contained in:
@@ -35,6 +35,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.mail.Address;
|
||||
@@ -56,6 +57,8 @@ public class EntityIdentity {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
public Long id;
|
||||
@NonNull
|
||||
public String uuid = UUID.randomUUID().toString();
|
||||
@NonNull
|
||||
public String name;
|
||||
@NonNull
|
||||
public String email;
|
||||
@@ -187,6 +190,7 @@ public class EntityIdentity {
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("uuid", uuid);
|
||||
json.put("name", name);
|
||||
json.put("email", email);
|
||||
// not account
|
||||
@@ -244,6 +248,10 @@ public class EntityIdentity {
|
||||
public static EntityIdentity fromJSON(JSONObject json) throws JSONException {
|
||||
EntityIdentity identity = new EntityIdentity();
|
||||
identity.id = json.getLong("id");
|
||||
|
||||
if (json.has("uuid"))
|
||||
identity.uuid = json.getString("uuid");
|
||||
|
||||
identity.name = json.getString("name");
|
||||
identity.email = json.getString("email");
|
||||
if (json.has("display") && !json.isNull("display"))
|
||||
@@ -315,7 +323,8 @@ public class EntityIdentity {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof EntityIdentity) {
|
||||
EntityIdentity other = (EntityIdentity) obj;
|
||||
return (this.name.equals(other.name) &&
|
||||
return (Objects.equals(this.uuid, other.uuid) &&
|
||||
this.name.equals(other.name) &&
|
||||
this.email.equals(other.email) &&
|
||||
this.account.equals(other.account) &&
|
||||
Objects.equals(this.display, other.display) &&
|
||||
|
||||
Reference in New Issue
Block a user