@@ -45,25 +45,30 @@ class CoderRestClientService {
45
45
* @throws [AuthenticationResponseException] if authentication failed.
46
46
*/
47
47
fun initClientSession (url : URL , token : String , headerCommand : String? ): User {
48
- client = CoderRestClient (url, token, headerCommand)
48
+ client = CoderRestClient (url, token, headerCommand, null )
49
49
me = client.me()
50
50
buildVersion = client.buildInfo().version
51
51
isReady = true
52
52
return me
53
53
}
54
54
}
55
55
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
+ ) {
57
60
private var httpClient: OkHttpClient
58
61
private var retroRestClient: CoderV2RestFacade
59
62
60
63
init {
61
64
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
+ }
63
68
64
69
httpClient = OkHttpClient .Builder ()
65
70
.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()) }
67
72
.addInterceptor {
68
73
var request = it.request()
69
74
val headers = getHeaders(url, headerCommand)
0 commit comments