summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2020-07-27 23:44:20 -0400
committerHubert Chathi <hubert@uhoreg.ca>2020-07-27 23:44:20 -0400
commit36239eb82a54af9c4881eb57269c5267358db018 (patch)
tree26a62f4b8f7b66279e6a393fcaeb17ec1b0bd306 /lib
parentuse Jason instead of Poison (diff)
add test for sync, and fix some bugs
Diffstat (limited to 'lib')
-rw-r--r--lib/polyjuice/client/sync.ex9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/polyjuice/client/sync.ex b/lib/polyjuice/client/sync.ex
index 67b83fd..416c336 100644
--- a/lib/polyjuice/client/sync.ex
+++ b/lib/polyjuice/client/sync.ex
@@ -1,4 +1,4 @@
-# Copyright 2019 Hubert Chathi <hubert@uhoreg.ca>
+# Copyright 2019-2020 Hubert Chathi <hubert@uhoreg.ca>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -58,6 +58,11 @@ defmodule Polyjuice.Client.Sync do
listener,
opts
) do
+ # Make sure the URL ends with a slash, so that URI.merge doesn't clobber
+ # the last path component. (URI.merge is smart enough to drop the double
+ # "/" if it already ends with a slash.)
+ homeserver_url = homeserver_url <> "/"
+
# Figure out how to handle the filter (if any): can we pass it in straight
# to the query, or do we need to get its ID. And if we get its ID, do we
# already have it, or do we need to send it to the server?
@@ -301,7 +306,7 @@ defmodule Polyjuice.Client.Sync do
timeline = Map.get(room, "timeline", %{})
if Map.get(timeline, "limited", false) do
- with {:ok, prev_batch} <- Map.get(timeline, "prev_batch") do
+ with {:ok, prev_batch} <- Map.fetch(timeline, "prev_batch") do
state.send.({:limited, roomname, prev_batch})
end
end