Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Fixing the github sha
Acho Arnold2af5d556da31
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 338d0883..48158d9a 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -51,7 +51,7 @@ jobs:run: yarn test- name: Build 🏗️- run: mv .env.production .env && yarn generate+ run: mv .env.production .env && GITHUB_SHA=${{GITHUB_SHA}}; yarn generate- name: Deploy 🚀uses: FirebaseExtended/action-hosting-deploy@v0diff --git a/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt b/android/app/src/main/java/com/httpsms/HttpSmsApiService.ktindex 8b64e59e..3847ee70 100644--- a/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt+++ b/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt@@ -16,6 +16,7 @@ import java.util.logging.Logger.getLoggerclass HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {private val apiKeyHeader = "x-api-key"+ private val clientVersionHeader = "X-Client-Version"private val jsonMediaType = "application/json; charset=utf-8".toMediaType()private val client = OkHttpClient.Builder().retryOnConnectionFailure(true).build()@@ -36,6 +37,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {val request: Request = Request.Builder().url(baseURL.resolve("/v1/messages/outstanding?message_id=${messageID}").toURL()).header(apiKeyHeader, apiKey)+ .header(clientVersionHeader, BuildConfig.VERSION_NAME).build()val response = client.newCall(request).execute()@@ -85,6 +87,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {.url(baseURL.resolve("/v1/messages/receive").toURL()).post(body.toRequestBody(jsonMediaType)).header(apiKeyHeader, apiKey)+ .header(clientVersionHeader, BuildConfig.VERSION_NAME).build()val response = client.newCall(request).execute()@@ -109,6 +112,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {.url(baseURL.resolve("/v1/heartbeats").toURL()).post(body.toRequestBody(jsonMediaType)).header(apiKeyHeader, apiKey)+ .header(clientVersionHeader, BuildConfig.VERSION_NAME).build()val response = client.newCall(request).execute()@@ -143,6 +147,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {.url(baseURL.resolve("/v1/messages/${messageId}/events").toURL()).post(body.toRequestBody(jsonMediaType)).header(apiKeyHeader, apiKey)+ .header(clientVersionHeader, BuildConfig.VERSION_NAME).build()val response = client.newCall(request).execute()@@ -169,6 +174,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {.url(baseURL.resolve("/v1/phones").toURL()).put(body.toRequestBody(jsonMediaType)).header(apiKeyHeader, apiKey)+ .header(clientVersionHeader, BuildConfig.VERSION_NAME).build()val response = client.newCall(request).execute()@@ -187,6 +193,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {val request: Request = Request.Builder().url(baseURL.resolve("/v1/users/me").toURL()).header(apiKeyHeader, apiKey)+ .header(clientVersionHeader, BuildConfig.VERSION_NAME).get().build()@@ -194,7 +201,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {val response = client.newCall(request).execute()if (!response.isSuccessful) {Timber.e("error response [${response.body?.string()}] with code [${response.code}] while verifying apiKey [$apiKey]")- return Pair("Cannot validate the API key. Check if it is correct and try again.", null);+ return Pair("Cannot validate the API key. Check if it is correct and try again.", null)}response.close()diff --git a/web/plugins/axios.ts b/web/plugins/axios.tsindex ad0d00bb..a46a0320 100644--- a/web/plugins/axios.ts+++ b/web/plugins/axios.ts@@ -2,10 +2,19 @@ import axios from 'axios'const client = axios.create({baseURL: process.env.BASE_URL || 'http://localhost:8000',+ headers: {+ common: {+ 'X-Client-Version': process.env.GITHUB_SHA || 'dev',+ },+ },})export function setAuthHeader(token: string | null) {client.defaults.headers.Authorization = 'Bearer ' + token}+export function setApiKey(apiKey: string | null) {+ client.defaults.headers['x-api-key'] = apiKey+}+export default client