add edit admin permissions

This commit is contained in:
2025-07-24 18:15:34 +03:30
parent 626b3c2fb4
commit a26736b6ba
5 changed files with 185 additions and 45 deletions
@@ -636,4 +636,18 @@ public class ChannelDatabase {
return subscriberIds;
}
public static boolean updateAdminPermissions(UUID channelId, UUID userId, JSONObject permissions) {
String sql = "UPDATE channel_subscribers SET permissions = ?::jsonb WHERE channel_id = ? AND user_id = ? AND role = 'admin'";
try (Connection conn = ConnectionDb.connect();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, permissions.toString());
stmt.setObject(2, channelId);
stmt.setObject(3, userId);
return stmt.executeUpdate() > 0;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
}
@@ -615,4 +615,18 @@ public class GroupDatabase {
return memberIds;
}
public static boolean updateAdminPermissions(UUID groupId, UUID userId, JSONObject permissions) {
String sql = "UPDATE group_members SET permissions = ?::jsonb WHERE group_id = ? AND user_id = ? AND role = 'admin'";
try (Connection conn = ConnectionDb.connect();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, permissions.toString());
stmt.setObject(2, groupId);
stmt.setObject(3, userId);
return stmt.executeUpdate() > 0;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
}