@commonpub/layer 0.3.15 → 0.3.17
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.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"files": [
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"zod": "^4.3.6",
|
|
47
47
|
"@commonpub/auth": "0.5.0",
|
|
48
48
|
"@commonpub/config": "0.7.0",
|
|
49
|
+
"@commonpub/docs": "0.5.2",
|
|
49
50
|
"@commonpub/editor": "0.5.0",
|
|
50
51
|
"@commonpub/protocol": "0.9.4",
|
|
51
|
-
"@commonpub/
|
|
52
|
-
"@commonpub/schema": "0.8.12",
|
|
52
|
+
"@commonpub/server": "2.12.1",
|
|
53
53
|
"@commonpub/learning": "0.5.0",
|
|
54
|
-
"@commonpub/
|
|
55
|
-
"@commonpub/
|
|
54
|
+
"@commonpub/ui": "0.7.1",
|
|
55
|
+
"@commonpub/schema": "0.8.12"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {}
|
|
58
58
|
}
|
|
@@ -358,7 +358,7 @@ useSeoMeta({
|
|
|
358
358
|
.cpub-btn-primary:hover:not(:disabled) { opacity: 0.9; }
|
|
359
359
|
.cpub-btn-primary:disabled { opacity: 0.5; cursor: default; }
|
|
360
360
|
.cpub-btn-danger { color: var(--red); border-color: var(--red); }
|
|
361
|
-
.cpub-btn-danger:hover { background: var(--red); color:
|
|
361
|
+
.cpub-btn-danger:hover { background: var(--red); color: var(--accent-text, #fff); }
|
|
362
362
|
|
|
363
363
|
/* Reply form */
|
|
364
364
|
.cpub-reply-form { margin-bottom: 16px; }
|
|
@@ -5,16 +5,37 @@ const conversationId = route.params.conversationId as string;
|
|
|
5
5
|
definePageMeta({ middleware: 'auth' });
|
|
6
6
|
|
|
7
7
|
const { user } = useAuth();
|
|
8
|
+
const toast = useToast();
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
interface ConvParticipant {
|
|
11
|
+
id: string;
|
|
12
|
+
displayName?: string;
|
|
13
|
+
username?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface MessageItem {
|
|
17
|
+
id: string;
|
|
18
|
+
senderId: string;
|
|
19
|
+
senderName?: string | null;
|
|
20
|
+
senderAvatarUrl?: string | null;
|
|
21
|
+
body: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { data: convInfo } = useLazyFetch<{ id: string; participants: ConvParticipant[] }>(`/api/messages/${conversationId}/info`, {
|
|
26
|
+
default: () => ({ id: conversationId, participants: [] }),
|
|
11
27
|
});
|
|
12
28
|
|
|
13
|
-
const { data: initialMessages, refresh } = useLazyFetch<
|
|
29
|
+
const { data: initialMessages, refresh } = useLazyFetch<MessageItem[]>(`/api/messages/${conversationId}`, {
|
|
14
30
|
default: () => [],
|
|
15
31
|
});
|
|
16
32
|
|
|
17
|
-
const messages = ref
|
|
33
|
+
const messages = ref<MessageItem[]>([]);
|
|
34
|
+
|
|
35
|
+
// Sync with lazy fetch when it resolves
|
|
36
|
+
watch(initialMessages, (val) => {
|
|
37
|
+
if (val?.length) messages.value = [...val];
|
|
38
|
+
}, { immediate: true });
|
|
18
39
|
|
|
19
40
|
// SSE real-time stream
|
|
20
41
|
let eventSource: EventSource | null = null;
|
|
@@ -51,22 +72,23 @@ const participantLabel = computed(() => {
|
|
|
51
72
|
const parts = convInfo.value?.participants ?? [];
|
|
52
73
|
if (!parts.length) return 'Conversation';
|
|
53
74
|
const others = parts
|
|
54
|
-
.filter((p
|
|
55
|
-
.map((p
|
|
75
|
+
.filter((p) => p.id !== user.value?.id)
|
|
76
|
+
.map((p) => p.displayName || p.username || p.id);
|
|
56
77
|
return others.length > 0 ? others.join(', ') : 'Conversation';
|
|
57
78
|
});
|
|
58
79
|
|
|
59
80
|
useSeoMeta({ title: () => `Message — ${participantLabel.value}` });
|
|
60
81
|
|
|
61
82
|
async function handleSend(text: string): Promise<void> {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
try {
|
|
84
|
+
await $fetch(`/api/messages/${conversationId}` as string, {
|
|
85
|
+
method: 'POST',
|
|
86
|
+
body: { body: text },
|
|
87
|
+
});
|
|
88
|
+
// SSE will pick up the new message, but also do an immediate refresh for responsiveness
|
|
89
|
+
await refresh();
|
|
90
|
+
} catch {
|
|
91
|
+
toast.error('Failed to send message');
|
|
70
92
|
}
|
|
71
93
|
}
|
|
72
94
|
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { backfillHubFromOutbox, fetchRemoteHubFollowers, repairFederatedHubPostActors } from '@commonpub/server';
|
|
2
|
+
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
requireFeature('federation');
|
|
5
|
+
requireFeature('federateHubs');
|
|
6
|
+
requireAdmin(event);
|
|
7
|
+
|
|
8
|
+
const db = useDB();
|
|
9
|
+
const config = useConfig();
|
|
10
|
+
const { id } = parseParams(event, { id: 'uuid' });
|
|
11
|
+
|
|
12
|
+
// Run all three operations
|
|
13
|
+
const [backfillResult, followersResult, repaired] = await Promise.all([
|
|
14
|
+
backfillHubFromOutbox(db, id, config.instance.domain).catch((err) => {
|
|
15
|
+
console.error('[hub-backfill] Failed:', err);
|
|
16
|
+
return { processed: 0, errors: 1 };
|
|
17
|
+
}),
|
|
18
|
+
fetchRemoteHubFollowers(db, id).catch((err) => {
|
|
19
|
+
console.error('[hub-followers] Failed:', err);
|
|
20
|
+
return { fetched: 0, errors: 1 };
|
|
21
|
+
}),
|
|
22
|
+
repairFederatedHubPostActors(db).catch(() => 0),
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
backfill: backfillResult,
|
|
27
|
+
followers: followersResult,
|
|
28
|
+
repairedActors: repaired,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { likePost, unlikePost, hasLikedPost, getHubBySlug, getPostById, federateHubPostLike, checkBan } from '@commonpub/server';
|
|
1
|
+
import { likePost, unlikePost, hasLikedPost, getHubBySlug, getPostById, federateHubPostLike, federateHubPostUnlike, checkBan } from '@commonpub/server';
|
|
2
2
|
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
4
|
const user = requireAuth(event);
|
|
@@ -19,6 +19,12 @@ export default defineEventHandler(async (event) => {
|
|
|
19
19
|
const alreadyLiked = await hasLikedPost(db, user.id, postId);
|
|
20
20
|
if (alreadyLiked) {
|
|
21
21
|
await unlikePost(db, user.id, postId);
|
|
22
|
+
// Federate the unlike (fire-and-forget)
|
|
23
|
+
if (config.features.federation && config.features.federateHubs) {
|
|
24
|
+
federateHubPostUnlike(db, user.id, postId, slug, config.instance.domain).catch((err) => {
|
|
25
|
+
console.error('[hub-federation] Failed to federate post unlike:', err);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
22
28
|
return { liked: false };
|
|
23
29
|
}
|
|
24
30
|
await likePost(db, user.id, postId);
|