From f820baa410f7954d3e80a280ec8d04392630f30b Mon Sep 17 00:00:00 2001 From: lesion Date: Mon, 20 Nov 2023 23:15:28 +0100 Subject: [PATCH] adds and removes friendly instances --- components/Footer.vue | 21 ++++++---- components/admin/Federation.vue | 29 ++++++-------- server/api/controller/instance.js | 40 ++++++++++++++++--- server/api/controller/settings.js | 2 +- server/api/index.js | 1 + server/api/models/ap_user.js | 1 + server/federation/users.js | 2 +- .../migrations/20231110214302-federation.js | 3 ++ 8 files changed, 67 insertions(+), 32 deletions(-) diff --git a/components/Footer.vue b/components/Footer.vue index dabd6864..3e653374 100644 --- a/components/Footer.vue +++ b/components/Footer.vue @@ -8,21 +8,21 @@ v-footer(aria-label='Footer') :key='link.label' color='primary' text :href='link.href' :to='link.to' :target="link.href && '_blank'") {{link.label}} - v-menu(v-if='settings.enable_trusted_instances && settings.trusted_instances && settings.trusted_instances.length' + v-menu(v-if='settings.enable_trusted_instances && trusted_instances?.length' offset-y bottom open-on-hover transition="slide-y-transition") template(v-slot:activator="{ on, attrs }") v-btn.ml-1(v-bind='attrs' v-on='on' color='primary' text) {{ settings.trusted_instances_label || $t('admin.trusted_instances_label_default')}} v-list(subheaders two-lines) - v-list-item(v-for='instance in settings.trusted_instances' + v-list-item(v-for='instance in trusted_instances' :key='instance.name' target='_blank' - :href='instance.url' + :href='instance.ap_id' two-line) + //- p {{ instance.object }} v-list-item-avatar - v-img(:src='`${instance.url}/logo.png`') + v-img(:src='instance.object.icon.url') v-list-item-content - v-list-item-title {{instance.name}} - v-list-item-subtitle {{instance.label}} + v-list-item-title {{instance.object.preferredUsername}} v-btn.ml-1(v-if='settings.enable_federation' color='primary' text rel='me' @click.prevent='showFollowMe=true') {{$t('event.interact_with_me')}} v-spacer @@ -37,9 +37,16 @@ export default { components: { FollowMe }, data () { return { - showFollowMe: false + showFollowMe: false, + trusted_instances: [] } }, + created () { + this.$root.$on('update_friendly_instances', this.$fetch) + }, + async fetch () { + this.trusted_instances = await this.$axios.$get('/instances/friendly') + }, computed: { ...mapState(['settings']), footerLinks () { diff --git a/components/admin/Federation.vue b/components/admin/Federation.vue index 054eb88e..0e2f5980 100644 --- a/components/admin/Federation.vue +++ b/components/admin/Federation.vue @@ -78,7 +78,6 @@ v-container