mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 08:32:23 +01:00
fix: a regression in federation
This commit is contained in:
parent
75dd77551d
commit
fd1e1421e7
3 changed files with 17 additions and 6 deletions
|
@ -168,8 +168,8 @@ export default {
|
||||||
if (!this.$refs.form.validate()) { return }
|
if (!this.$refs.form.validate()) { return }
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
this.instance_url = this.instance_url.replace(/\/$/, '')
|
this.source_url = this.source_url.replace(/\/$/, '')
|
||||||
await this.$axios.$post('/ap_actors/add_trust', { url: this.instance_url })
|
await this.$axios.$post('/ap_actors/add_trust', { url: this.source_url })
|
||||||
this.$refs.form.reset()
|
this.$refs.form.reset()
|
||||||
this.$fetch()
|
this.$fetch()
|
||||||
this.dialogAddTrustedSource = false
|
this.dialogAddTrustedSource = false
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const { APUser, Instance, Event, Resource } = require('../models/models')
|
const { APUser, Instance, Event, Resource } = require('../models/models')
|
||||||
const { getActor, unfollowActor, followActor, getInstance } = require('../../federation/helpers')
|
const { getActor, unfollowActor, followActor, getInstance } = require('../../federation/helpers')
|
||||||
|
const Sequelize = require('sequelize')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const get = require('lodash/get')
|
const get = require('lodash/get')
|
||||||
const log = require('../../log')
|
const log = require('../../log')
|
||||||
|
|
|
@ -108,7 +108,14 @@ const Helpers = {
|
||||||
method,
|
method,
|
||||||
...( method === 'post' && ({ data: message}))
|
...( method === 'post' && ({ data: message}))
|
||||||
})
|
})
|
||||||
log.debug(`[FEDI] signed ${ret.status} => %s`, ret.data)
|
|
||||||
|
// check if content-type is json
|
||||||
|
if (!ret?.headers?.['content-type'].includes('json')) {
|
||||||
|
log.error(`[FEDI] Error in sign and send, wrong content-type returned: ${ret.headers['content-type']}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug(`[FEDI] signed ${ret.status} => ${ret?.headers?.['content-type']}`)
|
||||||
return ret.data
|
return ret.data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error("[FEDI] Error in sign and send [%s]: %s", inbox, e?.response?.data?.error ?? e?.response?.statusMessage ?? '' + ' ' + String(e))
|
log.error("[FEDI] Error in sign and send [%s]: %s", inbox, e?.response?.data?.error ?? e?.response?.statusMessage ?? '' + ' ' + String(e))
|
||||||
|
@ -365,14 +372,14 @@ const Helpers = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async getOutbox(actor, limit) {
|
async getOutbox(actor, limit) {
|
||||||
log.debug('[FEDI] Get %s outbox', actor?.ap_id)
|
log.debug('[FEDI] Get %s outbox: %s', actor?.ap_id, actor?.object?.outbox)
|
||||||
|
|
||||||
if (!actor?.object?.outbox) return
|
if (!actor?.object?.outbox) return
|
||||||
try {
|
try {
|
||||||
let collection = await Helpers.signAndSend('', actor?.object?.outbox, 'get')
|
let collection = await Helpers.signAndSend('', actor?.object?.outbox, 'get')
|
||||||
// embedded collection
|
// embedded collection
|
||||||
if (typeof collection?.first !== 'string') {
|
if (typeof collection?.first !== 'string') {
|
||||||
return collection.first?.orderedItems ?? []
|
return collection?.first?.orderedItems ?? []
|
||||||
} else if (/^https?:\/\//.test(collection?.first)) {
|
} else if (/^https?:\/\//.test(collection?.first)) {
|
||||||
collection = await Helpers.signAndSend('', collection.first, 'get')
|
collection = await Helpers.signAndSend('', collection.first, 'get')
|
||||||
if (Array.isArray(collection?.orderedItems)) {
|
if (Array.isArray(collection?.orderedItems)) {
|
||||||
|
@ -423,7 +430,10 @@ const Helpers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
fedi_user = await Helpers.signAndSend('', URL, 'get')
|
fedi_user = await Helpers.signAndSend('', URL, 'get')
|
||||||
|
if (!fedi_user?.id) {
|
||||||
|
log.debug('[FEDI] getActor failed for %s', URL)
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (fedi_user) {
|
if (fedi_user) {
|
||||||
log.info('[FEDI] Create/Update a new AP User "%s" and associate it to instance "%s"', fedi_user?.id, instance.domain)
|
log.info('[FEDI] Create/Update a new AP User "%s" and associate it to instance "%s"', fedi_user?.id, instance.domain)
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue