@@ -34,7 +34,7 @@ interface ApiClient {
34
34
suspend fun subscribe (topics : List <String >): Flow <Envelope >
35
35
}
36
36
37
- data class GRPCApiClient (override val environment : XMTPEnvironment , val secure : Boolean = true ) :
37
+ data class GRPCApiClient (override val environment : XMTPEnvironment , val secure : Boolean = true , val appVersion : String? = null ) :
38
38
ApiClient , Closeable {
39
39
companion object {
40
40
val AUTHORIZATION_HEADER_KEY : Metadata .Key <String > =
@@ -102,6 +102,10 @@ data class GRPCApiClient(override val environment: XMTPEnvironment, val secure:
102
102
authToken?.let { token ->
103
103
headers.put(AUTHORIZATION_HEADER_KEY , " Bearer $token " )
104
104
}
105
+ headers.put(CLIENT_VERSION_HEADER_KEY , Constants .VERSION )
106
+ if (appVersion != null ) {
107
+ headers.put(APP_VERSION_HEADER_KEY , appVersion)
108
+ }
105
109
return client.query(request, headers = headers)
106
110
}
107
111
@@ -131,15 +135,24 @@ data class GRPCApiClient(override val environment: XMTPEnvironment, val secure:
131
135
}
132
136
133
137
headers.put(CLIENT_VERSION_HEADER_KEY , Constants .VERSION )
134
- headers.put(APP_VERSION_HEADER_KEY , Constants .VERSION )
138
+ if (appVersion != null ) {
139
+ headers.put(APP_VERSION_HEADER_KEY , appVersion)
140
+ }
135
141
136
142
return client.publish(request, headers)
137
143
}
138
144
139
145
override suspend fun subscribe (topics : List <String >): Flow <Envelope > {
140
146
val request =
141
147
MessageApiOuterClass .SubscribeRequest .newBuilder().addAllContentTopics(topics).build()
142
- return client.subscribe(request)
148
+ val headers = Metadata ()
149
+
150
+ headers.put(CLIENT_VERSION_HEADER_KEY , Constants .VERSION )
151
+ if (appVersion != null ) {
152
+ headers.put(APP_VERSION_HEADER_KEY , appVersion)
153
+ }
154
+
155
+ return client.subscribe(request, headers)
143
156
}
144
157
145
158
override fun close () {
0 commit comments