Skip to content

Commit 773669c

Browse files
committed
update user agent
1 parent f8b3eed commit 773669c

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

Agents/UserAgent/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ version: "3.8"
22

33
services:
44
user-agent:
5-
image: ghcr.io/cambridge-cares/user-agent:1.0.0
5+
image: ghcr.io/cambridge-cares/user-agent:2.0.0
66
build: .

Agents/UserAgent/stack-manager-config/inputs/config/services/user-agent-debug.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "user-agent",
55
"TaskTemplate": {
66
"ContainerSpec": {
7-
"Image": "user-agent:1.0.0",
7+
"Image": "user-agent:2.0.0",
88
"Mounts": [
99
{
1010
"Type": "bind",

Agents/UserAgent/stack-manager-config/inputs/config/services/user-agent.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "user-agent",
55
"TaskTemplate": {
66
"ContainerSpec": {
7-
"Image": "ghcr.io/cambridge-cares/user-agent:1.0.0",
7+
"Image": "ghcr.io/cambridge-cares/user-agent:2.0.0",
88
"Mounts": [
99
{
1010
"Type": "bind",

Apps/TimelineApp/core/sensor/src/main/java/uk/ac/cam/cares/jps/sensor/source/network/UserPhoneNetworkSource.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44

5+
import com.android.volley.AuthFailureError;
56
import com.android.volley.Request;
67
import com.android.volley.RequestQueue;
78
import com.android.volley.Response;
@@ -11,6 +12,9 @@
1112
import org.json.JSONException;
1213
import org.json.JSONObject;
1314

15+
import java.util.HashMap;
16+
import java.util.Map;
17+
1418
import okhttp3.HttpUrl;
1519

1620
/**
@@ -37,19 +41,28 @@ public void registerAppToUser(String userId, String deviceId, Response.Listener<
3741

3842
try {
3943
JSONObject body = new JSONObject();
40-
body.put("userId", userId);
44+
//body.put("userId", userId);
4145
body.put("phoneId", deviceId);
4246

4347
String url = HttpUrl.get(context.getString(uk.ac.cam.cares.jps.utils.R.string.host_with_port)).newBuilder()
4448
.addPathSegments(context.getString(uk.ac.cam.cares.jps.utils.R.string.useragent_registerphone))
4549
.build().toString();
4650

4751
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, body, jsonObject -> {
52+
4853
LOGGER.info(String.format("Phone id %s is register to user %s", deviceId, userId));
4954
onSuccessListener.onResponse(true);
5055
}, volleyError -> {
5156
LOGGER.error(volleyError.getMessage());
52-
});
57+
}) {
58+
59+
@Override
60+
public Map<String, String> getHeaders() throws AuthFailureError {
61+
Map<String, String> headers = new HashMap<>();
62+
headers.put("Authorization", "Bearer " + userId); // Ensure this is the correct user
63+
return headers;
64+
}
65+
};
5366

5467
requestQueue.add(request);
5568
} catch (JSONException e) {

Deploy/stacks/timeline/prod/stack-manager/inputs/config/services/user-agent.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "user-agent",
55
"TaskTemplate": {
66
"ContainerSpec": {
7-
"Image": "ghcr.io/cambridge-cares/user-agent:1.0.0",
7+
"Image": "ghcr.io/cambridge-cares/user-agent:2.0.0",
88
"Mounts": [
99
{
1010
"Type": "bind",

Deploy/stacks/timeline/test/stack-manager/inputs/config/services/user-agent.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "user-agent",
55
"TaskTemplate": {
66
"ContainerSpec": {
7-
"Image": "ghcr.io/cambridge-cares/user-agent:1.0.0",
7+
"Image": "ghcr.io/cambridge-cares/user-agent:2.0.0",
88
"Mounts": [
99
{
1010
"Type": "bind",

0 commit comments

Comments
 (0)