Skip to content

Commit 1eb0a41

Browse files
committed
chore: rename sms fields
1 parent 0e7309a commit 1eb0a41

File tree

11 files changed

+213
-213
lines changed

11 files changed

+213
-213
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Matrix to Acrobits Proxy
22

3-
This service acts as a proxy between an Acrobits softphone client and a Matrix homeserver, allowing users to send and receive Matrix messages through an SMS-like interface.
3+
This service acts as a proxy between an Acrobits softphone client and a Matrix homeserver, allowing users to send and receive Matrix messages through an -like interface.
44

55
The proxy is written in Go and uses the following key technologies:
66
- **Web Framework**: `github.com/labstack/echo/v4`
@@ -17,7 +17,7 @@ The proxy is configured via environment variables. Minimal required env:
1717
- `PROXY_PORT` (optional): port to listen on (default: `8080`)
1818
- `AS_USER_ID` (optional): the user ID of the Application Service bot (default: `@_acrobits_proxy:matrix.example`)
1919
- `LOGLEVEL` (optional): logging verbosity level - `DEBUG`, `INFO`, `WARNING`, `CRITICAL` (default: `INFO`)
20-
- `MAPPING_FILE` (optional): path to a JSON file containing SMS-to-Matrix mappings to load at startup
20+
- `MAPPING_FILE` (optional): path to a JSON file containing -to-Matrix mappings to load at startup
2121
- `PUSH_TOKEN_DB_PATH` (optional): path to a database file for storing push tokens
2222

2323
Building and running
@@ -48,7 +48,7 @@ For debugging mapping and API issues, set `LOGLEVEL=DEBUG` to see detailed trace
4848

4949
### Loading Mappings from File
5050

51-
You can pre-load SMS-to-Matrix mappings at startup by providing a `MAPPING_FILE` environment variable pointing to a JSON file. This is useful for initializing the proxy with a set of known mappings.
51+
You can pre-load -to-Matrix mappings at startup by providing a `MAPPING_FILE` environment variable pointing to a JSON file. This is useful for initializing the proxy with a set of known mappings.
5252

5353
See `docs/example-mappings.json` for an example format.
5454

api/routes.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func RegisterRoutes(e *echo.Echo, svc *service.MessageService, adminToken string
2020
e.POST("/api/client/send_message", h.sendMessage)
2121
e.POST("/api/client/fetch_messages", h.fetchMessages)
2222
e.POST("/api/client/push_token_report", h.pushTokenReport)
23-
e.POST("/api/internal/map_sms_to_matrix", h.postMapping)
24-
e.GET("/api/internal/map_sms_to_matrix", h.getMapping)
23+
e.POST("/api/internal/map_number_to_matrix", h.postMapping)
24+
e.GET("/api/internal/map_number_to_matrix", h.getMapping)
2525
e.GET("/api/internal/push_tokens", h.getPushTokens)
2626
e.DELETE("/api/internal/push_tokens", h.resetPushTokens)
2727
}
@@ -39,18 +39,18 @@ func (h handler) sendMessage(c echo.Context) error {
3939
return echo.NewHTTPError(http.StatusBadRequest, "invalid payload")
4040
}
4141

42-
logger.Debug().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.SMSTo).Msg("processing send message request")
43-
logger.Debug().Str("endpoint", "send_message").Str("raw_from", req.From).Str("raw_to", req.SMSTo).Msg("raw identifiers for recipient resolution")
42+
logger.Debug().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.To).Msg("processing send message request")
43+
logger.Debug().Str("endpoint", "send_message").Str("raw_from", req.From).Str("raw_to", req.To).Msg("raw identifiers for recipient resolution")
4444

4545
resp, err := h.svc.SendMessage(c.Request().Context(), &req)
4646
if err != nil {
47-
logger.Error().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.SMSTo).Err(err).Msg("failed to send message")
47+
logger.Error().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.To).Err(err).Msg("failed to send message")
4848
// Add extra context to help debugging recipient resolution
49-
logger.Debug().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.SMSTo).Msg("send_message handler returning error to client; check mapping store and AS configuration")
49+
logger.Debug().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.To).Msg("send_message handler returning error to client; check mapping store and AS configuration")
5050
return mapServiceError(err)
5151
}
5252

53-
logger.Info().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.SMSTo).Str("sms_id", resp.SMSID).Msg("message sent successfully")
53+
logger.Info().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.To).Str("message_id", resp.ID).Msg("message sent successfully")
5454
return c.JSON(http.StatusOK, resp)
5555
}
5656

@@ -69,7 +69,7 @@ func (h handler) fetchMessages(c echo.Context) error {
6969
return mapServiceError(err)
7070
}
7171

72-
logger.Info().Str("endpoint", "fetch_messages").Str("username", req.Username).Int("received", len(resp.ReceivedSMSS)).Int("sent", len(resp.SentSMSS)).Msg("messages fetched successfully")
72+
logger.Info().Str("endpoint", "fetch_messages").Str("username", req.Username).Int("received", len(resp.ReceivedMessages)).Int("sent", len(resp.SentMessages)).Msg("messages fetched successfully")
7373
return c.JSON(http.StatusOK, resp)
7474
}
7575

@@ -103,15 +103,15 @@ func (h handler) postMapping(c echo.Context) error {
103103
return echo.NewHTTPError(http.StatusBadRequest, "invalid payload")
104104
}
105105

106-
logger.Debug().Str("endpoint", "post_mapping").Str("sms_number", req.SMSNumber).Str("room_id", req.RoomID).Msg("saving mapping")
106+
logger.Debug().Str("endpoint", "post_mapping").Str("number", req.Number).Str("room_id", req.RoomID).Msg("saving mapping")
107107

108108
resp, err := h.svc.SaveMapping(&req)
109109
if err != nil {
110-
logger.Error().Str("endpoint", "post_mapping").Str("sms_number", req.SMSNumber).Err(err).Msg("failed to save mapping")
110+
logger.Error().Str("endpoint", "post_mapping").Str("number", req.Number).Err(err).Msg("failed to save mapping")
111111
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
112112
}
113113

114-
logger.Info().Str("endpoint", "post_mapping").Str("sms_number", req.SMSNumber).Str("room_id", req.RoomID).Msg("mapping saved successfully")
114+
logger.Info().Str("endpoint", "post_mapping").Str("number", req.Number).Str("room_id", req.RoomID).Msg("mapping saved successfully")
115115
return c.JSON(http.StatusOK, resp)
116116
}
117117

@@ -120,10 +120,10 @@ func (h handler) getMapping(c echo.Context) error {
120120
return err
121121
}
122122

123-
smsNumber := strings.TrimSpace(c.QueryParam("sms_number"))
124-
if smsNumber == "" {
123+
number := strings.TrimSpace(c.QueryParam("number"))
124+
if number == "" {
125125
logger.Debug().Str("endpoint", "get_mapping").Msg("listing all mappings")
126-
// return full mappings list when sms_number is not provided
126+
// return full mappings list when number is not provided
127127
respList, err := h.svc.ListMappings()
128128
if err != nil {
129129
logger.Error().Str("endpoint", "get_mapping").Err(err).Msg("failed to list mappings")
@@ -133,19 +133,19 @@ func (h handler) getMapping(c echo.Context) error {
133133
return c.JSON(http.StatusOK, respList)
134134
}
135135

136-
logger.Debug().Str("endpoint", "get_mapping").Str("sms_number", smsNumber).Msg("looking up mapping")
136+
logger.Debug().Str("endpoint", "get_mapping").Str("number", number).Msg("looking up mapping")
137137

138-
resp, err := h.svc.LookupMapping(smsNumber)
138+
resp, err := h.svc.LookupMapping(number)
139139
if err != nil {
140140
if errors.Is(err, service.ErrMappingNotFound) {
141-
logger.Warn().Str("endpoint", "get_mapping").Str("sms_number", smsNumber).Msg("mapping not found")
141+
logger.Warn().Str("endpoint", "get_mapping").Str("number", number).Msg("mapping not found")
142142
return echo.NewHTTPError(http.StatusNotFound, err.Error())
143143
}
144-
logger.Error().Str("endpoint", "get_mapping").Str("sms_number", smsNumber).Err(err).Msg("failed to lookup mapping")
144+
logger.Error().Str("endpoint", "get_mapping").Str("number", number).Err(err).Msg("failed to lookup mapping")
145145
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
146146
}
147147

148-
logger.Info().Str("endpoint", "get_mapping").Str("sms_number", smsNumber).Str("room_id", resp.RoomID).Msg("mapping found")
148+
logger.Info().Str("endpoint", "get_mapping").Str("number", number).Str("room_id", resp.RoomID).Msg("mapping found")
149149
return c.JSON(http.StatusOK, resp)
150150
}
151151

docs/DEPLOY_NS8.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,67 +131,67 @@ After the above logins, you can send a message from giacomo to mario:
131131
```
132132
curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message -H "Content-Type: application/json" -d '{
133133
"from": "@giacomo:synapse.gs.nethserver.net",
134-
"sms_to": "@mario:synapse.gs.nethserver.net",
135-
"sms_body": "Hello Mario — this is Giacomo (curl test)",
134+
"to": "@mario:synapse.gs.nethserver.net",
135+
"body": "Hello Mario — this is Giacomo (curl test)",
136136
"content_type": "text/plain"
137137
}'
138138
```
139139

140140
Response example:
141141
```
142-
{"sms_id":"$VnrNZPmkkrgcqd2Lq15K9GKYuKXaNi-PrEsx6WLHfDs"}
142+
{"message":"$VnrNZPmkkrgcqd2Lq15K9GKYuKXaNi-PrEsx6WLHfDs"}
143143
```
144144

145145
Mario reply:
146146
```
147147
curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message -H "Content-Type: application/json" -d '{
148148
"from": "@mario:synapse.gs.nethserver.net",
149-
"sms_to": "@giacomo:synapse.gs.nethserver.net",
150-
"sms_body": "Hello Giacomo — this is Mario reply (curl test)",
149+
"to": "@giacomo:synapse.gs.nethserver.net",
150+
"body": "Hello Giacomo — this is Mario reply (curl test)",
151151
"content_type": "text/plain"
152152
}'
153153
```
154154

155155

156-
Map SMS number (91201) to Matrix user (giacomo):
156+
Map number (91201) to Matrix user (giacomo):
157157
```
158-
curl "http://127.0.0.1:8080/api/internal/map_sms_to_matrix" -H "Content-Type: application/json" -H "X-Super-Admin-Token: secret" -d '{
159-
"sms_number": "91201",
158+
curl "http://127.0.0.1:8080/api/internal/map_number_to_matrix" -H "Content-Type: application/json" -H "X-Super-Admin-Token: secret" -d '{
159+
"number": "91201",
160160
"matrix_id": "@giacomo:synapse.gs.nethserver.net",
161161
"room_id": "!giacomo-room:synapse.gs.nethserver.net"
162162
}'
163163
```
164164

165-
Map SMS number (91202) to Matrix user (mario):
165+
Map number (91202) to Matrix user (mario):
166166
```
167-
curl "http://127.0.0.1:8080/api/internal/map_sms_to_matrix" -H "Content-Type: application/json" -H "X-Super-Admin-Token: secret" -d '{
168-
"sms_number": "91202",
167+
curl "http://127.0.0.1:8080/api/internal/map_number_to_matrix" -H "Content-Type: application/json" -H "X-Super-Admin-Token: secret" -d '{
168+
"number": "91202",
169169
"matrix_id": "@mario:synapse.gs.nethserver.net",
170170
"room_id": "!mario-room:synapse.gs.nethserver.net"
171171
}'
172172
```
173173

174174
Retrieve current mappings:
175175
```
176-
curl "http://127.0.0.1:8080/api/internal/map_sms_to_matrix" -H "X-Super-Admin-Token: secret"
176+
curl "http://127.0.0.1:8080/api/internal/map_number_to_matrix" -H "X-Super-Admin-Token: secret"
177177
```
178178

179-
Send message using mapped SMS number (91201) - Giacomo to Mario:
179+
Send message using mapped number (91201) - Giacomo to Mario:
180180
```
181181
curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message -H "Content-Type: application/json" -d '{
182182
"from": "@giacomo:synapse.gs.nethserver.net",
183-
"sms_to": "91202",
184-
"sms_body": "Hello Mario — this is Giacomo (curl test using mapped number)",
183+
"to": "91202",
184+
"body": "Hello Mario — this is Giacomo (curl test using mapped number)",
185185
"content_type": "text/plain"
186186
}'
187187
```
188188

189-
Send message using mapped SMS number (91202) - Mario to Giacomo:
189+
Send message using mapped number (91202) - Mario to Giacomo:
190190
```
191191
curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message -H "Content-Type: application/json" -d '{
192192
"from": "@mario:synapse.gs.nethserver.net",
193-
"sms_to": "91201",
194-
"sms_body": "Hello Giacomo — this is Mario reply (curl test using mapped number)",
193+
"to": "91201",
194+
"body": "Hello Giacomo — this is Mario reply (curl test using mapped number)",
195195
"content_type": "text/plain"
196196
}'
197197
```
@@ -200,8 +200,8 @@ Send message using mapped numbers - Giacomo to Mario:
200200
```
201201
curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message -H "Content-Type: application/json" -d '{
202202
"from": "91201",
203-
"sms_to": "91202",
204-
"sms_body": "Hello Mario — this is Giacomo (curl test using both mapped numbers)",
203+
"to": "91202",
204+
"body": "Hello Mario — this is Giacomo (curl test using both mapped numbers)",
205205
"content_type": "text/plain"
206206
}'
207207
```

docs/example-mappings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[
22
{
3-
"sms_number": "91201",
3+
"number": "91201",
44
"matrix_id": "@giacomo:synapse.gs.nethserver.net",
55
"room_id": "!giacomo-room:synapse.gs.nethserver.net",
66
"user_name": "Giacomo Rossi"
77
},
88
{
9-
"sms_number": "91202",
9+
"number": "91202",
1010
"matrix_id": "@mario:synapse.gs.nethserver.net",
1111
"room_id": "!mario-room:synapse.gs.nethserver.net",
1212
"user_name": "Mario Bianchi"

docs/openapi.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ paths:
3434
description: The 'since' token from the last sync.
3535
last_sent_id:
3636
type: string
37-
description: The sms_id of the last sent message.
37+
description: The message id of the last sent message.
3838
device:
3939
type: string
4040
description: Device identifier (e.g., 'ACROBITS').
@@ -57,7 +57,7 @@ paths:
5757
5858
The `from` field can be:
5959
- A full Matrix ID (e.g., @user:server.com) - used directly
60-
- A phone number (e.g., +1234567890) - resolved to Matrix ID via SMS-to-Matrix mapping if available
60+
- A phone number (e.g., +1234567890) - resolved to Matrix ID via -to-Matrix mapping if available
6161
6262
If a phone number is provided and a mapping exists, the message is sent on behalf of the mapped Matrix user.
6363
If a phone number is provided but no mapping exists, the phone number is used as the sender ID.
@@ -71,19 +71,19 @@ paths:
7171
type: object
7272
required:
7373
- from
74-
- sms_to
75-
- sms_body
74+
- to
75+
- body
7676
properties:
7777
from:
7878
type: string
7979
description: The sender - either a full Matrix ID (e.g., @user:server.com) or a phone number (e.g., +1234567890).
8080
password:
8181
type: string
8282
description: This field is ignored. Kept for client compatibility.
83-
sms_to:
83+
to:
8484
type: string
8585
description: Recipient Matrix ID, Alias, or mapped phone number.
86-
sms_body:
86+
body:
8787
type: string
8888
description: The message content.
8989
content_type:
@@ -100,7 +100,7 @@ paths:
100100
schema:
101101
type: object
102102
properties:
103-
sms_id:
103+
message_id:
104104
type: string
105105
description: The Matrix event ID of the sent message.
106106
'400':
@@ -144,11 +144,11 @@ paths:
144144
response:
145145
{}
146146

147-
/api/internal/map_sms_to_matrix:
147+
/api/internal/map_number_to_matrix:
148148
post:
149-
summary: Register or update an SMS-to-Matrix mapping
149+
summary: Register or update an -to-Matrix mapping
150150
description: |
151-
Creates or overwrites the mapping between an SMS number (or other identifier) and
151+
Creates or overwrites the mapping between an number (or other identifier) and
152152
a Matrix room. Requires the `X-Super-Admin-Token` header.
153153
parameters:
154154
- in: header
@@ -187,11 +187,11 @@ paths:
187187
required: true
188188
description: The Application Service token (as_token).
189189
- in: query
190-
name: sms_number
190+
name: number
191191
schema:
192192
type: string
193193
required: false
194-
description: The SMS number or identifier previously mapped. If omitted, the endpoint returns the full list of mappings.
194+
description: The number or identifier previously mapped. If omitted, the endpoint returns the full list of mappings.
195195
responses:
196196
'200':
197197
description: Mapping found
@@ -271,7 +271,7 @@ components:
271271
Message:
272272
type: object
273273
properties:
274-
sms_id:
274+
id:
275275
type: string
276276
description: Unique identifier (Matrix Event ID).
277277
sending_date:
@@ -284,7 +284,7 @@ components:
284284
recipient:
285285
type: string
286286
description: Recipient address/ID (Room ID).
287-
sms_text:
287+
text:
288288
type: string
289289
description: Message body.
290290
content_type:
@@ -300,23 +300,23 @@ components:
300300
type: string
301301
format: date-time
302302
description: Current server time in RFC 3339.
303-
received_smss:
303+
received_messages:
304304
type: array
305305
items:
306306
$ref: '#/components/schemas/Message'
307-
sent_smss:
307+
sent_messages:
308308
type: array
309309
items:
310310
$ref: '#/components/schemas/Message'
311311
MappingRequest:
312312
type: object
313313
required:
314-
- sms_number
314+
- number
315315
- room_id
316316
properties:
317-
sms_number:
317+
number:
318318
type: string
319-
description: SMS number or bridged identifier to map.
319+
description: number or bridged identifier to map.
320320
matrix_id:
321321
type: string
322322
description: Optional Matrix user to use when auto-creating DMs.
@@ -329,7 +329,7 @@ components:
329329
MappingResponse:
330330
type: object
331331
properties:
332-
sms_number:
332+
number:
333333
type: string
334334
matrix_id:
335335
type: string

0 commit comments

Comments
 (0)