Skip to content

Commit 2af5d55

Browse files
committed
Fixing the github sha
1 parent 5fdeab3 commit 2af5d55

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
run: yarn test
5252

5353
- name: Build 🏗️
54-
run: mv .env.production .env && yarn generate
54+
run: mv .env.production .env && GITHUB_SHA=${{GITHUB_SHA}}; yarn generate
5555

5656
- name: Deploy 🚀
5757
uses: FirebaseExtended/action-hosting-deploy@v0

android/app/src/main/java/com/httpsms/HttpSmsApiService.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import java.util.logging.Logger.getLogger
1616

1717
class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
1818
private val apiKeyHeader = "x-api-key"
19+
private val clientVersionHeader = "X-Client-Version"
1920
private val jsonMediaType = "application/json; charset=utf-8".toMediaType()
2021
private val client = OkHttpClient.Builder().retryOnConnectionFailure(true).build()
2122

@@ -36,6 +37,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
3637
val request: Request = Request.Builder()
3738
.url(baseURL.resolve("/v1/messages/outstanding?message_id=${messageID}").toURL())
3839
.header(apiKeyHeader, apiKey)
40+
.header(clientVersionHeader, BuildConfig.VERSION_NAME)
3941
.build()
4042

4143
val response = client.newCall(request).execute()
@@ -85,6 +87,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
8587
.url(baseURL.resolve("/v1/messages/receive").toURL())
8688
.post(body.toRequestBody(jsonMediaType))
8789
.header(apiKeyHeader, apiKey)
90+
.header(clientVersionHeader, BuildConfig.VERSION_NAME)
8891
.build()
8992

9093
val response = client.newCall(request).execute()
@@ -109,6 +112,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
109112
.url(baseURL.resolve("/v1/heartbeats").toURL())
110113
.post(body.toRequestBody(jsonMediaType))
111114
.header(apiKeyHeader, apiKey)
115+
.header(clientVersionHeader, BuildConfig.VERSION_NAME)
112116
.build()
113117

114118
val response = client.newCall(request).execute()
@@ -143,6 +147,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
143147
.url(baseURL.resolve("/v1/messages/${messageId}/events").toURL())
144148
.post(body.toRequestBody(jsonMediaType))
145149
.header(apiKeyHeader, apiKey)
150+
.header(clientVersionHeader, BuildConfig.VERSION_NAME)
146151
.build()
147152

148153
val response = client.newCall(request).execute()
@@ -169,6 +174,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
169174
.url(baseURL.resolve("/v1/phones").toURL())
170175
.put(body.toRequestBody(jsonMediaType))
171176
.header(apiKeyHeader, apiKey)
177+
.header(clientVersionHeader, BuildConfig.VERSION_NAME)
172178
.build()
173179

174180
val response = client.newCall(request).execute()
@@ -187,14 +193,15 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
187193
val request: Request = Request.Builder()
188194
.url(baseURL.resolve("/v1/users/me").toURL())
189195
.header(apiKeyHeader, apiKey)
196+
.header(clientVersionHeader, BuildConfig.VERSION_NAME)
190197
.get()
191198
.build()
192199

193200
try {
194201
val response = client.newCall(request).execute()
195202
if (!response.isSuccessful) {
196203
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while verifying apiKey [$apiKey]")
197-
return Pair("Cannot validate the API key. Check if it is correct and try again.", null);
204+
return Pair("Cannot validate the API key. Check if it is correct and try again.", null)
198205
}
199206

200207
response.close()

web/plugins/axios.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ import axios from 'axios'
22

33
const client = axios.create({
44
baseURL: process.env.BASE_URL || 'http://localhost:8000',
5+
headers: {
6+
common: {
7+
'X-Client-Version': process.env.GITHUB_SHA || 'dev',
8+
},
9+
},
510
})
611

712
export function setAuthHeader(token: string | null) {
813
client.defaults.headers.Authorization = 'Bearer ' + token
914
}
1015

16+
export function setApiKey(apiKey: string | null) {
17+
client.defaults.headers['x-api-key'] = apiKey
18+
}
19+
1120
export default client

0 commit comments

Comments
 (0)