From b587a51ee855986174450c22f7f8c74cda598161 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 15 Feb 2024 23:29:22 +0100 Subject: [PATCH] implement suggested changes --- .../components/Federation/CommunityVisualizeItem.vue | 6 +++--- admin/src/graphql/allCommunities.js | 2 +- backend/src/graphql/model/Community.ts | 4 ---- .../src/graphql/resolver/CommunityResolver.test.ts | 11 ++++++++++- backend/src/seeds/graphql/queries.ts | 1 + .../FederatedCommunity.ts | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/admin/src/components/Federation/CommunityVisualizeItem.vue b/admin/src/components/Federation/CommunityVisualizeItem.vue index 8d993f1d7..24e6b3712 100644 --- a/admin/src/components/Federation/CommunityVisualizeItem.vue +++ b/admin/src/components/Federation/CommunityVisualizeItem.vue @@ -15,8 +15,8 @@ - - {{ $t('federation.communityUuid') }} {{ item.communityUuid }} + + {{ $t('federation.communityUuid') }} {{ item.uuid }} {{ $t('federation.authenticatedAt') }} {{ item.authenticatedAt }} @@ -144,7 +144,7 @@ export default { .mutate({ mutation: updateHomeCommunity, variables: { - uuid: this.item.communityUuid, + uuid: this.item.uuid, gmsApiKey: gmsApiKey, }, }) diff --git a/admin/src/graphql/allCommunities.js b/admin/src/graphql/allCommunities.js index e14e533df..6379086c7 100644 --- a/admin/src/graphql/allCommunities.js +++ b/admin/src/graphql/allCommunities.js @@ -6,7 +6,7 @@ export const allCommunities = gql` foreign url publicKey - communityUuid + uuid authenticatedAt name description diff --git a/backend/src/graphql/model/Community.ts b/backend/src/graphql/model/Community.ts index 0c4424fa3..db860216a 100644 --- a/backend/src/graphql/model/Community.ts +++ b/backend/src/graphql/model/Community.ts @@ -31,7 +31,6 @@ export class Community { if (dbCom.publicKey && dbCom.publicKey.length === 32) { this.publicKey = dbCom.publicKey.toString('hex') } - this.communityUuid = dbCom.communityUuid this.creationDate = dbCom.creationDate this.createdAt = dbCom.createdAt this.updatedAt = dbCom.updatedAt @@ -61,9 +60,6 @@ export class Community { @Field(() => String) publicKey: string - @Field(() => String, { nullable: true }) - communityUuid: string | null - @Field(() => Date, { nullable: true }) creationDate: Date | null diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index bb58b3e5b..af714e746 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -165,6 +165,7 @@ describe('CommunityResolver', () => { foreign: homeCom3.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[2].public), endPoint: expect.stringMatching('http://localhost/api/'), + apiVersion: '2_0', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -176,6 +177,7 @@ describe('CommunityResolver', () => { foreign: homeCom2.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[1].public), endPoint: expect.stringMatching('http://localhost/api/'), + apiVersion: '1_1', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -187,6 +189,7 @@ describe('CommunityResolver', () => { foreign: homeCom1.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[0].public), endPoint: expect.stringMatching('http://localhost/api/'), + apiVersion: '1_0', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -222,7 +225,7 @@ describe('CommunityResolver', () => { foreignCom3 = DbFederatedCommunity.create() foreignCom3.foreign = true foreignCom3.publicKey = Buffer.from(ed25519KeyPairStaticHex[5].public, 'hex') - foreignCom3.apiVersion = '1_2' + foreignCom3.apiVersion = '2_0' foreignCom3.endPoint = 'http://remotehost/api' foreignCom3.createdAt = new Date() await DbFederatedCommunity.insert(foreignCom3) @@ -237,6 +240,7 @@ describe('CommunityResolver', () => { foreign: homeCom3.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[2].public), endPoint: expect.stringMatching('http://localhost/api/'), + apiVersion: '2_0', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -248,6 +252,7 @@ describe('CommunityResolver', () => { foreign: homeCom2.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[1].public), endPoint: expect.stringMatching('http://localhost/api/'), + apiVersion: '1_1', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -259,6 +264,7 @@ describe('CommunityResolver', () => { foreign: homeCom1.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[0].public), endPoint: expect.stringMatching('http://localhost/api/'), + apiVersion: '1_0', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -270,6 +276,7 @@ describe('CommunityResolver', () => { foreign: foreignCom3.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[5].public), endPoint: expect.stringMatching('http://remotehost/api/'), + apiVersion: '2_0', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -281,6 +288,7 @@ describe('CommunityResolver', () => { foreign: foreignCom2.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[4].public), endPoint: expect.stringMatching('http://remotehost/api/'), + apiVersion: '1_1', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, @@ -292,6 +300,7 @@ describe('CommunityResolver', () => { foreign: foreignCom1.foreign, publicKey: expect.stringMatching(ed25519KeyPairStaticHex[3].public), endPoint: expect.stringMatching('http://remotehost/api/'), + apiVersion: '1_0', lastAnnouncedAt: null, verifiedAt: null, lastErrorAt: null, diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index f988783b8..c3005ff96 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -157,6 +157,7 @@ export const getCommunities = gql` foreign publicKey endPoint + apiVersion lastAnnouncedAt verifiedAt lastErrorAt diff --git a/database/entity/0083-join_community_federated_communities/FederatedCommunity.ts b/database/entity/0083-join_community_federated_communities/FederatedCommunity.ts index 7e13744c8..b5eb64ea1 100644 --- a/database/entity/0083-join_community_federated_communities/FederatedCommunity.ts +++ b/database/entity/0083-join_community_federated_communities/FederatedCommunity.ts @@ -52,7 +52,7 @@ export class FederatedCommunity extends BaseEntity { }) updatedAt: Date | null - @ManyToOne(() => Community, (community) => community.federatedCommunities) // Assuming you have a User entity with 'accounts' relation + @ManyToOne(() => Community, (community) => community.federatedCommunities) @JoinColumn({ name: 'public_key', referencedColumnName: 'publicKey' }) community?: Community }