@commonpub/layer 0.3.29 → 0.3.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commonpub/layer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"files": [
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"vue": "^3.4.0",
|
|
45
45
|
"vue-router": "^4.3.0",
|
|
46
46
|
"zod": "^4.3.6",
|
|
47
|
-
"@commonpub/config": "0.7.1",
|
|
48
47
|
"@commonpub/auth": "0.5.0",
|
|
49
|
-
"@commonpub/
|
|
48
|
+
"@commonpub/config": "0.7.1",
|
|
50
49
|
"@commonpub/docs": "0.5.2",
|
|
51
|
-
"@commonpub/
|
|
50
|
+
"@commonpub/editor": "0.5.0",
|
|
52
51
|
"@commonpub/learning": "0.5.0",
|
|
53
|
-
"@commonpub/
|
|
52
|
+
"@commonpub/protocol": "0.9.5",
|
|
53
|
+
"@commonpub/server": "2.18.0",
|
|
54
54
|
"@commonpub/schema": "0.8.13",
|
|
55
|
-
"@commonpub/
|
|
55
|
+
"@commonpub/ui": "0.7.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { getHubBySlug, getHubFederatedFollowers, getHubActorUri } from '@commonpub/server';
|
|
2
|
+
import { hubMembers, users } from '@commonpub/schema';
|
|
3
|
+
import { eq, and } from 'drizzle-orm';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
* Hub Group actor followers collection.
|
|
5
|
-
* Returns an OrderedCollection of
|
|
6
|
+
* Hub Group actor followers/members collection.
|
|
7
|
+
* Returns an OrderedCollection of both local members (as Person actor URIs)
|
|
8
|
+
* and remote AP followers. Remote instances use this to populate member lists.
|
|
6
9
|
*/
|
|
7
10
|
export default defineEventHandler(async (event) => {
|
|
8
11
|
const config = useConfig();
|
|
@@ -24,16 +27,29 @@ export default defineEventHandler(async (event) => {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
const hubActorUri = getHubActorUri(domain, slug);
|
|
30
|
+
|
|
31
|
+
// Get remote AP followers
|
|
27
32
|
const followers = await getHubFederatedFollowers(db, hub.id);
|
|
28
33
|
const followerUris = followers.map((f) => f.followerActorUri);
|
|
29
34
|
|
|
35
|
+
// Get local hub members as Person actor URIs
|
|
36
|
+
const localMembers = await db
|
|
37
|
+
.select({ username: users.username })
|
|
38
|
+
.from(hubMembers)
|
|
39
|
+
.innerJoin(users, eq(hubMembers.userId, users.id))
|
|
40
|
+
.where(and(eq(hubMembers.hubId, hub.id), eq(hubMembers.status, 'active')));
|
|
41
|
+
const memberUris = localMembers.map((m) => `https://${domain}/users/${m.username}`);
|
|
42
|
+
|
|
43
|
+
// Combine and deduplicate
|
|
44
|
+
const allUris = [...new Set([...memberUris, ...followerUris])];
|
|
45
|
+
|
|
30
46
|
setResponseHeader(event, 'content-type', 'application/activity+json');
|
|
31
47
|
|
|
32
48
|
return {
|
|
33
49
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
34
50
|
id: `${hubActorUri}/followers`,
|
|
35
51
|
type: 'OrderedCollection',
|
|
36
|
-
totalItems:
|
|
37
|
-
orderedItems:
|
|
52
|
+
totalItems: allUris.length,
|
|
53
|
+
orderedItems: allUris,
|
|
38
54
|
};
|
|
39
55
|
});
|