1 /*
2  * Copyright (C) 2021 Finn Herzfeld
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 package io.finn.signald.clientprotocol.v1;
19 
20 import com.fasterxml.jackson.annotation.JsonProperty;
21 import io.finn.signald.annotations.Doc;
22 import io.finn.signald.annotations.ExampleValue;
23 import org.signal.storageservice.protos.groups.local.DecryptedMember;
24 import org.signal.storageservice.protos.groups.local.DecryptedPendingMember;
25 import org.whispersystems.signalservice.api.util.UuidUtil;
26 
27 public class GroupMember {
28   @ExampleValue(ExampleValue.REMOTE_UUID) public String uuid;
29   @ExampleValue("\"DEFAULT\"") @Doc("possible values are: UNKNOWN, DEFAULT, ADMINISTRATOR and UNRECOGNIZED") public String role;
30   @JsonProperty("joined_revision") public int joinedAtRevision;
31 
GroupMember(@sonPropertyR) String u, @JsonProperty(R) String r)32   public GroupMember(@JsonProperty("uuid") String u, @JsonProperty("role") String r) {
33     uuid = u;
34     role = r;
35   }
36 
GroupMember(DecryptedMember d)37   public GroupMember(DecryptedMember d) {
38     uuid = UuidUtil.fromByteStringOrUnknown(d.getUuid()).toString();
39     role = d.getRole().name();
40     joinedAtRevision = d.getJoinedAtRevision();
41   }
42 
GroupMember(DecryptedPendingMember d)43   public GroupMember(DecryptedPendingMember d) {
44     uuid = UuidUtil.fromByteStringOrUnknown(d.getUuid()).toString();
45     role = d.getRole().name();
46   }
47 }
48