From 5903475f4ab246c3814ad955bcf014d2b103731b Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 12 Dec 2018 11:01:40 -0800 Subject: [PATCH] Include endpoint for device name --- .../controllers/AccountController.java | 9 +++++++++ .../textsecuregcm/entities/DeviceName.java | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/main/java/org/whispersystems/textsecuregcm/entities/DeviceName.java diff --git a/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index 800e3c25d..c4107cc0b 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -31,6 +31,7 @@ import org.whispersystems.textsecuregcm.auth.TurnToken; import org.whispersystems.textsecuregcm.auth.TurnTokenGenerator; import org.whispersystems.textsecuregcm.entities.AccountAttributes; import org.whispersystems.textsecuregcm.entities.ApnRegistrationId; +import org.whispersystems.textsecuregcm.entities.DeviceName; import org.whispersystems.textsecuregcm.entities.GcmRegistrationId; import org.whispersystems.textsecuregcm.entities.RegistrationLock; import org.whispersystems.textsecuregcm.entities.RegistrationLockFailure; @@ -308,6 +309,14 @@ public class AccountController { accounts.update(account); } + @Timed + @PUT + @Path("/name/") + public void setName(@Auth Account account, @Valid DeviceName deviceName) { + account.getAuthenticatedDevice().get().setName(deviceName.getDeviceName()); + accounts.update(account); + } + @Timed @PUT @Path("/attributes/") diff --git a/src/main/java/org/whispersystems/textsecuregcm/entities/DeviceName.java b/src/main/java/org/whispersystems/textsecuregcm/entities/DeviceName.java new file mode 100644 index 000000000..fc3b908b0 --- /dev/null +++ b/src/main/java/org/whispersystems/textsecuregcm/entities/DeviceName.java @@ -0,0 +1,19 @@ +package org.whispersystems.textsecuregcm.entities; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.NotEmpty; + +public class DeviceName { + + @JsonProperty + @NotEmpty + @Length(max = 300, message = "This field must be less than 300 characters") + private String deviceName; + + public DeviceName() {} + + public String getDeviceName() { + return deviceName; + } +}