@@ -45,25 +45,30 @@ class CoderRestClientService {
4545 * @throws [AuthenticationResponseException] if authentication failed.
4646 */
4747 fun initClientSession (url : URL , token : String , headerCommand : String? ): User {
48- client = CoderRestClient (url, token, headerCommand)
48+ client = CoderRestClient (url, token, headerCommand, null )
4949 me = client.me()
5050 buildVersion = client.buildInfo().version
5151 isReady = true
5252 return me
5353 }
5454}
5555
56- class CoderRestClient (var url : URL , var token : String , var headerCommand : String? ) {
56+ class CoderRestClient (var url : URL , var token : String ,
57+ private var headerCommand : String? ,
58+ private var pluginVersion : String? ,
59+ ) {
5760 private var httpClient: OkHttpClient
5861 private var retroRestClient: CoderV2RestFacade
5962
6063 init {
6164 val gson: Gson = GsonBuilder ().registerTypeAdapter(Instant ::class .java, InstantConverter ()).setPrettyPrinting().create()
62- val pluginVersion = PluginManagerCore .getPlugin(PluginId .getId(" com.coder.gateway" ))!! // this is the id from the plugin.xml
65+ if (pluginVersion.isNullOrBlank()) {
66+ pluginVersion = PluginManagerCore .getPlugin(PluginId .getId(" com.coder.gateway" ))!! .version // this is the id from the plugin.xml
67+ }
6368
6469 httpClient = OkHttpClient .Builder ()
6570 .addInterceptor { it.proceed(it.request().newBuilder().addHeader(" Coder-Session-Token" , token).build()) }
66- .addInterceptor { it.proceed(it.request().newBuilder().addHeader(" User-Agent" , " Coder Gateway/${pluginVersion.version } (${SystemInfo .getOsNameAndVersion()} ; ${SystemInfo .OS_ARCH } )" ).build()) }
71+ .addInterceptor { it.proceed(it.request().newBuilder().addHeader(" User-Agent" , " Coder Gateway/${pluginVersion} (${SystemInfo .getOsNameAndVersion()} ; ${SystemInfo .OS_ARCH } )" ).build()) }
6772 .addInterceptor {
6873 var request = it.request()
6974 val headers = getHeaders(url, headerCommand)
0 commit comments