From 63dd5b2f0615fef02f818dc4e69d51a1b68300c4 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sat, 23 Jun 2018 19:41:58 +0200 Subject: [PATCH 1/2] Ensure we use proper URL to connect to websocket --- front/src/store/instance.js | 11 ++++------- front/src/views/instance/Timeline.vue | 5 ++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/front/src/store/instance.js b/front/src/store/instance.js index 555bd8239..dfd6a9db8 100644 --- a/front/src/store/instance.js +++ b/front/src/store/instance.js @@ -54,19 +54,16 @@ export default { state.events = value }, instanceUrl: (state, value) => { + if (value && !value.endsWith('/')) { + value = value + '/' + } state.instanceUrl = value if (!value) { axios.defaults.baseURL = null return } - let apiUrl let suffix = 'api/v1/' - if (state.instanceUrl.endsWith('/')) { - apiUrl = state.instanceUrl + suffix - } else { - apiUrl = state.instanceUrl + '/' + suffix - } - axios.defaults.baseURL = apiUrl + axios.defaults.baseURL = state.instanceUrl + suffix } }, getters: { diff --git a/front/src/views/instance/Timeline.vue b/front/src/views/instance/Timeline.vue index 03bd5a537..a5647b7bf 100644 --- a/front/src/views/instance/Timeline.vue +++ b/front/src/views/instance/Timeline.vue @@ -78,8 +78,11 @@ export default { // let token = 'test' const bridge = new WebSocketBridge() this.bridge = bridge + let url = this.$store.getters['instance/absoluteUrl'](`api/v1/instance/activity?token=${token}`) + url = url.replace('http://', 'ws://') + url = url.replace('https://', 'wss://') bridge.connect( - `/api/v1/instance/activity?token=${token}`, + url, null, {reconnectInterval: 5000}) bridge.listen(function (event) { From 0e1203336dc11c7f2e23247219bc63eeca84e36b Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sun, 24 Jun 2018 13:56:06 +0200 Subject: [PATCH 2/2] Fixed randomly failing test --- api/funkwhale_api/music/factories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/funkwhale_api/music/factories.py b/api/funkwhale_api/music/factories.py index c8f4bf322..9bcc4350f 100644 --- a/api/funkwhale_api/music/factories.py +++ b/api/funkwhale_api/music/factories.py @@ -89,7 +89,7 @@ class ImportJobFactory(factory.django.DjangoModelFactory): batch = factory.SubFactory(ImportBatchFactory) source = factory.Faker("url") mbid = factory.Faker("uuid4") - replace_if_duplicate = factory.Faker("boolean") + replace_if_duplicate = False class Meta: model = "music.ImportJob"