mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Refactor getGroup method
This commit is contained in:
parent
fbcc1cfb50
commit
f06eeb01b9
1 changed files with 11 additions and 5 deletions
|
@ -150,23 +150,29 @@ public class GroupStore {
|
||||||
|
|
||||||
public GroupInfo getGroup(GroupId groupId) {
|
public GroupInfo getGroup(GroupId groupId) {
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
if (groupId instanceof GroupIdV1 groupIdV1) {
|
return getGroup(connection, groupId);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException("Failed read from group store", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupInfo getGroup(final Connection connection, final GroupId groupId) throws SQLException {
|
||||||
|
switch (groupId) {
|
||||||
|
case GroupIdV1 groupIdV1 -> {
|
||||||
final var group = getGroup(connection, groupIdV1);
|
final var group = getGroup(connection, groupIdV1);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
return getGroupV2ByV1Id(connection, groupIdV1);
|
return getGroupV2ByV1Id(connection, groupIdV1);
|
||||||
} else if (groupId instanceof GroupIdV2 groupIdV2) {
|
}
|
||||||
|
case GroupIdV2 groupIdV2 -> {
|
||||||
final var group = getGroup(connection, groupIdV2);
|
final var group = getGroup(connection, groupIdV2);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
return getGroupV1ByV2Id(connection, groupIdV2);
|
return getGroupV1ByV2Id(connection, groupIdV2);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException("Failed read from group store", e);
|
|
||||||
}
|
}
|
||||||
throw new AssertionError("Invalid group id type");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
|
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue