From 36239eb82a54af9c4881eb57269c5267358db018 Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Mon, 27 Jul 2020 23:44:20 -0400 Subject: add test for sync, and fix some bugs --- lib/polyjuice/client/sync.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') 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 +# Copyright 2019-2020 Hubert Chathi # # 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 -- cgit v1.2.3