Frontends call the admin helpers directly, not through the connection
The channel, ban, privilege key, complaint, server log, offline message and avatar helpers are public, each method running in the background and answering a future; only the connection creates them. TeamspeakConnection and ServerSession hand them out, which drops 30 one-line forwarders from the connection. What the forwarders added moves into the helpers: the stop-at-the-first-refusal loops, the "sent" log lines, re-reading an edited channel's description and showing our own new avatar. The complaint and offline message length limits move with them. The icon chooser and the offline message composer take only their helper; the other dialogs still need the connection for the model. The connection's request runner is renamed Uplink, since session.ServerLink is the ts3server:// link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -248,17 +248,17 @@ class ServerController internal constructor(
|
||||
if (channelId > 0) conn.model.siblingsOf(channelId) else conn.model.childrenOf(parentId)
|
||||
|
||||
/** A channel's editable properties as the server has them. */
|
||||
suspend fun channelSettings(channelId: Int): Result<ChannelSettings> = conn.requestChannelSettings(channelId).result()
|
||||
suspend fun channelSettings(channelId: Int): Result<ChannelSettings> = session.channels().settings(channelId).result()
|
||||
|
||||
suspend fun editChannel(channelId: Int, changes: Map<String, String>): Result<Unit> =
|
||||
if (changes.isEmpty()) Result.success(Unit)
|
||||
else conn.applyChannelEdit(channelId, changes, emptyMap(), emptyList()).done()
|
||||
else session.channels().edit(channelId, changes, emptyMap(), emptyList()).done()
|
||||
|
||||
suspend fun createChannel(parentId: Int, settings: ChannelSettings): Result<Unit> =
|
||||
conn.createChannel(parentId, settings.creationParameters(), emptyMap()).result().map { }
|
||||
session.channels().create(parentId, settings.creationParameters(), emptyMap()).result().map { }
|
||||
|
||||
/** Deletes a channel, with its sub-channels and the clients in it moved out. */
|
||||
suspend fun deleteChannel(channelId: Int): Result<Unit> = conn.deleteChannel(channelId, true).done()
|
||||
suspend fun deleteChannel(channelId: Int): Result<Unit> = session.channels().delete(channelId, true).done()
|
||||
|
||||
// ---- files ----
|
||||
|
||||
@@ -325,13 +325,13 @@ class ServerController internal constructor(
|
||||
else suspendCoroutine { done -> conn.requestConnectionInfo(clientId) { done.resume(it) } }
|
||||
|
||||
/** The server's bans, or why they could not be read. */
|
||||
suspend fun banList(): Result<List<BanEntry>> = conn.requestBanList().result()
|
||||
suspend fun banList(): Result<List<BanEntry>> = session.bans().list().result()
|
||||
|
||||
suspend fun addBan(rule: BanRule): Result<Unit> = conn.addBan(rule).done()
|
||||
suspend fun addBan(rule: BanRule): Result<Unit> = session.bans().add(rule).done()
|
||||
|
||||
suspend fun replaceBan(banId: Int, rule: BanRule): Result<Unit> = conn.replaceBan(banId, rule).done()
|
||||
suspend fun replaceBan(banId: Int, rule: BanRule): Result<Unit> = session.bans().replace(banId, rule).done()
|
||||
|
||||
suspend fun deleteBans(banIds: Collection<Int>): Result<Unit> = conn.deleteBans(banIds).done()
|
||||
suspend fun deleteBans(banIds: Collection<Int>): Result<Unit> = session.bans().delete(banIds).done()
|
||||
|
||||
fun canDeleteBans(bans: Collection<BanEntry>): Boolean = permissions.canDeleteBans(bans, conn.selfUniqueId)
|
||||
|
||||
@@ -346,7 +346,7 @@ class ServerController internal constructor(
|
||||
File.createTempFile("avatar", null, app.cacheDir).apply { writeBytes(data) }
|
||||
}
|
||||
return try {
|
||||
conn.setAvatar(file).done()
|
||||
session.avatarAdmin().set(file).done()
|
||||
} finally {
|
||||
file.delete()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user