Compare commits

...

2 Commits

Author SHA1 Message Date
Alicia
93957dfc80 Make things a lil more robust to voipms errors 2024-05-08 23:39:37 -07:00
Alicia
3051df7a0d Fix issue with mime type on login route. Update container instructions 2024-04-13 11:15:15 -07:00
6 changed files with 46 additions and 7 deletions

20
CONTAINER.md Normal file
View File

@@ -0,0 +1,20 @@
# Maintainer instructions on how to update the docker container
Build the container
`docker build .`
Find the line in the output after the prod container has been built (it's the middle one after build and before dev), grab it's sha.
You can run `docker images` to check that it matches.
Tag the image
`docker tag codeberg.org/boxedtoast/slidgevoipms:latest <IMAGE ID>`
Login to codeberg (if you haven't already)
`docker login codeberg.org`
Push the image
`docker push codeberg.org/boxedtoast/slidgevoipms:latest`

View File

@@ -11,5 +11,4 @@ for general info on how to set up an XMPP server component.
### Containers ### Containers
Containers are not available on docker.io yet, but can be built locally from the Dockerfile. The container is available on codeberg. See the `docker-compose-prod.yml` for an example of how to pull it in.
The docker-compose.yml will bring up a development instance of slidge and prosody.

11
docker-compose-prod.yml Normal file
View File

@@ -0,0 +1,11 @@
slidgevoipms:
image: codeberg.org/boxedtoast/slidgevoipms:latest
container_name: slidgevoipms
restart: unless-stopped
networks:
- xmpp # should be the same one as your XMPP server
volumes:
- ./slidgevoipms.conf:/etc/slidge/conf.d/slidgevoipms.conf:ro
- ./slidgevoipmsattachments:/slidge-web # attachment directory
- ./slidgevoipmsdata:/var/lib/slidge:rw # slidge databases

View File

@@ -57,8 +57,13 @@ class Gateway(BaseGateway):
'method': 'getDIDsInfo', 'method': 'getDIDsInfo',
'content_type': 'json', 'content_type': 'json',
}) as response: }) as response:
json = await response.json() # For whatever cursed reason, this call sometimes returns with
if json['status'] == 'success': # text/html as the content type, so we disable the check
return try:
else: json = await response.json(content_type=None)
raise XMPPError("Received error from voipms") if json['status'] == 'success':
return
else:
raise XMPPError("Received error from voipms")
except:
raise XMPPError("Failure decoding response from voipms")

View File

@@ -92,6 +92,7 @@ class Session(BaseSession[str, Contact]):
'all_messages': 1, 'all_messages': 1,
'content_type': 'json', 'content_type': 'json',
}) as response: }) as response:
try:
json = await response.json() json = await response.json()
log.debug(f"received messages from voipms {json}") log.debug(f"received messages from voipms {json}")
@@ -99,6 +100,9 @@ class Session(BaseSession[str, Contact]):
return [] return []
else: else:
return json['sms'] return json['sms']
except client_exceptions.ContentTypeError:
log.warning("Received non-json response from voipms")
return []
async def on_file(self, chat: Contact, url: str, **_kwargs): async def on_file(self, chat: Contact, url: str, **_kwargs):
f = self.user.registration_form f = self.user.registration_form