Merge branch 'broken-websocket' into 'develop'
Ensure we use absolute URL to connect to websocket See merge request funkwhale/funkwhale!270
This commit is contained in:
commit
e068f4c102
|
@ -89,7 +89,7 @@ class ImportJobFactory(factory.django.DjangoModelFactory):
|
||||||
batch = factory.SubFactory(ImportBatchFactory)
|
batch = factory.SubFactory(ImportBatchFactory)
|
||||||
source = factory.Faker("url")
|
source = factory.Faker("url")
|
||||||
mbid = factory.Faker("uuid4")
|
mbid = factory.Faker("uuid4")
|
||||||
replace_if_duplicate = factory.Faker("boolean")
|
replace_if_duplicate = False
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = "music.ImportJob"
|
model = "music.ImportJob"
|
||||||
|
|
|
@ -54,19 +54,16 @@ export default {
|
||||||
state.events = value
|
state.events = value
|
||||||
},
|
},
|
||||||
instanceUrl: (state, value) => {
|
instanceUrl: (state, value) => {
|
||||||
|
if (value && !value.endsWith('/')) {
|
||||||
|
value = value + '/'
|
||||||
|
}
|
||||||
state.instanceUrl = value
|
state.instanceUrl = value
|
||||||
if (!value) {
|
if (!value) {
|
||||||
axios.defaults.baseURL = null
|
axios.defaults.baseURL = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let apiUrl
|
|
||||||
let suffix = 'api/v1/'
|
let suffix = 'api/v1/'
|
||||||
if (state.instanceUrl.endsWith('/')) {
|
axios.defaults.baseURL = state.instanceUrl + suffix
|
||||||
apiUrl = state.instanceUrl + suffix
|
|
||||||
} else {
|
|
||||||
apiUrl = state.instanceUrl + '/' + suffix
|
|
||||||
}
|
|
||||||
axios.defaults.baseURL = apiUrl
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
|
|
@ -78,8 +78,11 @@ export default {
|
||||||
// let token = 'test'
|
// let token = 'test'
|
||||||
const bridge = new WebSocketBridge()
|
const bridge = new WebSocketBridge()
|
||||||
this.bridge = bridge
|
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(
|
bridge.connect(
|
||||||
`/api/v1/instance/activity?token=${token}`,
|
url,
|
||||||
null,
|
null,
|
||||||
{reconnectInterval: 5000})
|
{reconnectInterval: 5000})
|
||||||
bridge.listen(function (event) {
|
bridge.listen(function (event) {
|
||||||
|
|
Loading…
Reference in New Issue