Skip to content

Commit ed2d442

Browse files
committed
chore: remove SMS word
1 parent d2d5523 commit ed2d442

File tree

12 files changed

+172
-172
lines changed

12 files changed

+172
-172
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: 15 additions & 15 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
}
@@ -50,7 +50,7 @@ func (h handler) sendMessage(c echo.Context) error {
5050
return mapServiceError(err)
5151
}
5252

53-
logger.Info().Str("endpoint", "send_message").Str("from", req.From).Str("to", req.To).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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message
139139

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

145145
Mario reply:
@@ -153,30 +153,30 @@ curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message
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",
@@ -186,7 +186,7 @@ curl -s -X POST https://synapse.gs.nethserver.net/m2a/api/client/send_message
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",

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: 16 additions & 16 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.
@@ -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

go.sum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
3030
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3131
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
3232
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
33-
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
33+
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8yjJKDIan90Nz0=
3434
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
3535
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
3636
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=

0 commit comments

Comments
 (0)