-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV2-3857: get_server_url implementation (#651)
- Loading branch information
Assaf Sapir
authored
Oct 3, 2023
1 parent
4e54965
commit 53abc37
Showing
4 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Common/src/main/java/com/tabnineCommon/chat/commandHandlers/GetServerUrlHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.tabnineCommon.chat.commandHandlers | ||
|
||
import com.google.gson.Gson | ||
import com.google.gson.JsonElement | ||
import com.intellij.openapi.project.Project | ||
import com.tabnineCommon.chat.commandHandlers.utils.getServerUrl | ||
|
||
data class ServerUrlResponse(val serverUrl: String) | ||
|
||
class GetServerUrlHandler(gson: Gson) : ChatMessageHandler<Unit, ServerUrlResponse>(gson) { | ||
override fun handle(payload: Unit?, project: Project): ServerUrlResponse { | ||
val serverUrl = getServerUrl() ?: "https://api.tabnine.com" | ||
return ServerUrlResponse(serverUrl) | ||
} | ||
|
||
override fun deserializeRequest(data: JsonElement?) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Common/src/main/java/com/tabnineCommon/chat/commandHandlers/utils/ServerUrl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tabnineCommon.chat.commandHandlers.utils | ||
|
||
import com.tabnineCommon.config.Config | ||
import com.tabnineCommon.general.StaticConfig | ||
|
||
fun getServerUrl(): String? { | ||
if (!Config.IS_SELF_HOSTED) return null | ||
return StaticConfig.getTabnineEnterpriseHost().orElse(null) | ||
} |