@songsid/agend 2.4.0-beta.25 → 2.4.0-beta.26
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/dist/agent-file-read.js +1 -1
- package/dist/agent-file-read.js.map +1 -1
- package/dist/auth-api.js +3 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +1 -1
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/delivery-outbox.js +4 -1
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-lock.d.ts +16 -0
- package/dist/fleet-lock.js +40 -0
- package/dist/fleet-lock.js.map +1 -1
- package/dist/fleet-manager.d.ts +20 -1
- package/dist/fleet-manager.js +154 -14
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +6 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +12 -1
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +3 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +7 -0
- package/dist/hub/client.js +7 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.js +6 -1
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +1 -0
- package/dist/hub/compose/server.js +3 -2
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/http/compose.js +3 -2
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/deps.d.ts +1 -0
- package/dist/hub/member/room-ask.d.ts +7 -8
- package/dist/hub/member/room-ask.js +52 -13
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-reaction-acks.d.ts +12 -0
- package/dist/hub/member/room-reaction-acks.js +44 -0
- package/dist/hub/member/room-reaction-acks.js.map +1 -0
- package/dist/hub/protocol.d.ts +4 -0
- package/dist/hub/protocol.js +2 -2
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/roles/audit-details.d.ts +2 -0
- package/dist/hub/roles/audit-details.js +1 -1
- package/dist/hub/roles/audit-details.js.map +1 -1
- package/dist/hub/roles/authority.d.ts +8 -3
- package/dist/hub/roles/authority.js +144 -102
- package/dist/hub/roles/authority.js.map +1 -1
- package/dist/hub/roles/delegation.js +2 -2
- package/dist/hub/roles/delegation.js.map +1 -1
- package/dist/hub/roles/model.d.ts +5 -2
- package/dist/hub/roles/model.js +5 -4
- package/dist/hub/roles/model.js.map +1 -1
- package/dist/hub/roles/review.js +2 -2
- package/dist/hub/roles/review.js.map +1 -1
- package/dist/hub/room-react-ack-model.d.ts +2 -0
- package/dist/hub/room-react-ack-model.js +3 -0
- package/dist/hub/room-react-ack-model.js.map +1 -0
- package/dist/hub/rooms/admin.d.ts +6 -0
- package/dist/hub/rooms/admin.js +33 -0
- package/dist/hub/rooms/admin.js.map +1 -1
- package/dist/hub/rooms/agents.d.ts +2 -0
- package/dist/hub/rooms/agents.js +44 -3
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +5 -1
- package/dist/hub/rooms/service.js +76 -24
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +2 -0
- package/dist/hub/server.js +6 -1
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/types.d.ts +2 -0
- package/dist/locale.js +2 -2
- package/dist/locale.js.map +1 -1
- package/dist/public-web-gateway.js +2 -0
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/recover.cjs +212 -26
- package/dist/request-contact-native.js +4 -0
- package/dist/request-contact-native.js.map +1 -1
- package/dist/scheduler/scheduler.d.ts +9 -0
- package/dist/scheduler/scheduler.js +26 -0
- package/dist/scheduler/scheduler.js.map +1 -1
- package/dist/scheduler/scheduler.test.js +17 -0
- package/dist/scheduler/scheduler.test.js.map +1 -1
- package/dist/settings-api.js +72 -0
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +13 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +11 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/ui/contact-auth-strings.js +7 -2
- package/dist/ui/contact-permissions.js +10 -2
- package/dist/ui/fleet-office-pack.d.ts +2 -2
- package/dist/ui/fleet-office-pack.js +25 -8
- package/dist/ui/fleet-office-vehicles.js +28 -11
- package/dist/ui/fleet-office-zones.js +2 -2
- package/dist/ui/fleet-office.js +25 -5
- package/dist/ui/hub-admin-rooms-strings.js +6 -2
- package/dist/ui/hub-admin-rooms.js +3 -1
- package/dist/ui/hub-group-search.js +2 -2
- package/dist/ui/hub-notify-keep.js +49 -0
- package/dist/ui/hub-role-view.js +1 -1
- package/dist/ui/hub-roles-strings.js +14 -10
- package/dist/ui/hub-roles.js +1 -1
- package/dist/ui/hub-room-notify.js +2 -1
- package/dist/ui/hub-room-strings.js +3 -3
- package/dist/ui/hub-room-thread.js +9 -4
- package/dist/ui/panel-hub.js +3 -2
- package/dist/ui/panel-needs.js +13 -5
- package/dist/ui/settings-update.js +13 -0
- package/dist/ui/shared/app-install.js +123 -0
- package/dist/ui/shared/app-shell.js +4 -2
- package/dist/ui/shared/app-update.js +16 -2
- package/dist/ui/shared/app.css +43 -0
- package/dist/ui/shared/app.js +3 -0
- package/dist/ui/shared/hub-chat.css +6 -0
- package/dist/ui/shared/ui-confirm.js +4 -3
- package/dist/ui/shared/ui-icons.js +2 -0
- package/dist/ui/shared/update-card-ui.js +419 -0
- package/dist/update-abandon.d.ts +26 -0
- package/dist/update-abandon.js +111 -0
- package/dist/update-abandon.js.map +1 -0
- package/dist/update-forward.d.ts +5 -19
- package/dist/update-forward.js +19 -75
- package/dist/update-forward.js.map +1 -1
- package/dist/update-goback.d.ts +90 -0
- package/dist/update-goback.js +260 -0
- package/dist/update-goback.js.map +1 -0
- package/dist/update-journal.d.ts +8 -0
- package/dist/update-journal.js +8 -2
- package/dist/update-journal.js.map +1 -1
- package/dist/update-package-restore.d.ts +11 -2
- package/dist/update-package-restore.js +16 -5
- package/dist/update-package-restore.js.map +1 -1
- package/dist/update-quiescence.d.ts +38 -9
- package/dist/update-quiescence.js +50 -10
- package/dist/update-quiescence.js.map +1 -1
- package/dist/update-recovery/recover.js +10 -0
- package/dist/update-recovery/recover.js.map +1 -1
- package/dist/update-recovery/runner.d.ts +4 -0
- package/dist/update-recovery/runner.js +38 -5
- package/dist/update-recovery/runner.js.map +1 -1
- package/dist/update-restore.d.ts +7 -1
- package/dist/update-restore.js +10 -5
- package/dist/update-restore.js.map +1 -1
- package/dist/update-retained.d.ts +28 -1
- package/dist/update-retained.js +28 -3
- package/dist/update-retained.js.map +1 -1
- package/dist/update-settings.d.ts +27 -0
- package/dist/update-settings.js +40 -0
- package/dist/update-settings.js.map +1 -1
- package/dist/update-snapshot-scope.js +1 -0
- package/dist/update-snapshot-scope.js.map +1 -1
- package/dist/web-icons.d.ts +11 -0
- package/dist/web-icons.js +14 -2
- package/dist/web-icons.js.map +1 -1
- package/dist/web-mentions.d.ts +27 -8
- package/dist/web-mentions.js +108 -1
- package/dist/web-mentions.js.map +1 -1
- package/dist/web-office-acts.js +3 -0
- package/dist/web-office-acts.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ import type { HubRoomListResult, HubRoomPostResult, HubRoomMembersResult, HubPeo
|
|
|
9
9
|
import type { RoomEvent, RoomMessage, RoomSystemEvent } from "./types.js";
|
|
10
10
|
import type { RoomInvitationHost } from "../invitations.js";
|
|
11
11
|
type DB = Database.Database;
|
|
12
|
+
export declare const ROOM_CREATION_HINT_MS = 60000;
|
|
12
13
|
export interface GroupRoomFileView {
|
|
13
14
|
id: string;
|
|
14
15
|
name: string;
|
|
@@ -43,6 +44,8 @@ export declare class HubGroupRooms {
|
|
|
43
44
|
private readonly core;
|
|
44
45
|
private readonly office;
|
|
45
46
|
private readonly appPosts;
|
|
47
|
+
/** Display hints only: never retain or reuse an operation permit. */
|
|
48
|
+
private readonly creationHints;
|
|
46
49
|
private listeners;
|
|
47
50
|
readonly agents: HubRoomAgents;
|
|
48
51
|
readonly assistant: HubRoomAssistant;
|
|
@@ -131,6 +134,7 @@ export declare class HubGroupRooms {
|
|
|
131
134
|
private summary;
|
|
132
135
|
private addAssistant;
|
|
133
136
|
private assistantRoom;
|
|
137
|
+
private creationHint;
|
|
134
138
|
list(ctx: HubRequestContext): Promise<{
|
|
135
139
|
rooms: ({
|
|
136
140
|
id: string;
|
|
@@ -197,7 +201,7 @@ export declare class HubGroupRooms {
|
|
|
197
201
|
name: string;
|
|
198
202
|
people: number;
|
|
199
203
|
}[]>;
|
|
200
|
-
private
|
|
204
|
+
private candidateAccess;
|
|
201
205
|
private groupSelection;
|
|
202
206
|
groupCandidate(ctx: HubRequestContext, id: string): Promise<{
|
|
203
207
|
kind: string;
|
|
@@ -4,13 +4,14 @@ import { normalizeRoomPurpose } from "./purpose.js";
|
|
|
4
4
|
import { ROOM_OFFICE_STYLES, newRoomOffice, officeAgent, officeOn, roomOfficeView, withLook, memberLook } from "./office.js";
|
|
5
5
|
import { agentIntro } from "../agent-intro.js";
|
|
6
6
|
import { countChainStop } from "../admin-dashboard.js";
|
|
7
|
+
import { performance } from "node:perf_hooks";
|
|
7
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { HubCatalogService, exposureOf, readExposure } from "../catalog.js";
|
|
10
11
|
import { RoomPostReplies } from "./post-replies.js";
|
|
11
12
|
import { HubGrantSearch } from "../grant-search.js";
|
|
12
13
|
import { HubRoomAssistant } from "./assistant.js";
|
|
13
|
-
import { canCreateRoom } from "./admin.js";
|
|
14
|
+
import { canCreateRoom, prepareRoomCreation } from "./admin.js";
|
|
14
15
|
import { HubRoomAgents } from "./agents.js";
|
|
15
16
|
import { personKeyString } from "../identity.js";
|
|
16
17
|
import { personFromString } from "../http/core.js";
|
|
@@ -26,6 +27,8 @@ import { RoomDirectoryCandidates, rememberRoomPeople, roomPersonLabels } from ".
|
|
|
26
27
|
import { isInlineImage } from "../attachments/limits.js";
|
|
27
28
|
import { HUB_ROOM_MENTION_FEEDBACK_CAPABILITY } from "../room-mention-feedback-model.js";
|
|
28
29
|
import { personalMentionRefusals, recordPersonalMentionRefusals } from "../personal/refusals.js";
|
|
30
|
+
export const ROOM_CREATION_HINT_MS = 60_000;
|
|
31
|
+
const ROOM_CREATION_HINT_LIMIT = 256;
|
|
29
32
|
const label = plain(120).transform(s => s.trim()).refine(s => s.length > 0 && !/[\u0000-\u001f\u007f]/.test(s));
|
|
30
33
|
const personId = z.string().max(128).refine(s => /^[a-z][a-z0-9_-]{0,63}\/[a-f0-9-]{36}$/.test(s));
|
|
31
34
|
const purpose = z.string().transform(normalizeRoomPurpose);
|
|
@@ -100,6 +103,8 @@ export class HubGroupRooms {
|
|
|
100
103
|
core;
|
|
101
104
|
office;
|
|
102
105
|
appPosts;
|
|
106
|
+
/** Display hints only: never retain or reuse an operation permit. */
|
|
107
|
+
creationHints = new Map();
|
|
103
108
|
listeners = new Set();
|
|
104
109
|
agents;
|
|
105
110
|
assistant;
|
|
@@ -197,7 +202,7 @@ export class HubGroupRooms {
|
|
|
197
202
|
return this.core.atomic(db => !!db.prepare("SELECT 1 FROM hub_room_members WHERE room_id=? AND kind='person' AND subject=?").get(event.roomId, person));
|
|
198
203
|
}
|
|
199
204
|
async close() { this.buttonsClosed = true; if (this.buttonsTimer)
|
|
200
|
-
clearTimeout(this.buttonsTimer); this.buttonsTimer = null; this.listeners.clear(); this.directory.close(); this.agentSearch.close(); this.agentReadBuckets.clear(); this.assistant.close(); await this.agents.close(); await this.postReplies.close(); }
|
|
205
|
+
clearTimeout(this.buttonsTimer); this.buttonsTimer = null; this.listeners.clear(); this.creationHints.clear(); this.directory.close(); this.agentSearch.close(); this.agentReadBuckets.clear(); this.assistant.close(); await this.agents.close(); await this.postReplies.close(); }
|
|
201
206
|
/** The direct-chat receiver shares this stream without changing its grant-backed delivery path. */
|
|
202
207
|
publish(event) { this.emit(event); }
|
|
203
208
|
/** C owns invitation checks; these synchronous effects remain on its current SQL transaction. */
|
|
@@ -320,8 +325,9 @@ export class HubGroupRooms {
|
|
|
320
325
|
const stopped = row.delivery_id && row.stage === "not-answered" ? db.prepare("SELECT 1 FROM hub_room_deliveries WHERE id=? AND reason_code='owner-stopped-sharing'").get(row.delivery_id) : null;
|
|
321
326
|
const missing = row.delivery_id && row.stage === "not-answered" ? db.prepare("SELECT 1 FROM hub_room_deliveries WHERE id=? AND reason_code='finished-without-answer'").get(row.delivery_id) : null;
|
|
322
327
|
const lapsed = row.delivery_id && row.stage === "not-answered" ? db.prepare("SELECT 1 FROM hub_room_deliveries WHERE id=? AND reason_code='share-needs-reshare'").get(row.delivery_id) : null;
|
|
328
|
+
const reactionAck = row.delivery_id && row.stage === "answered" ? db.prepare("SELECT 1 FROM hub_room_deliveries WHERE id=? AND state='answered' AND reason_code='acknowledged-by-reaction' AND answer_id IS NULL").get(row.delivery_id) : null;
|
|
323
329
|
const reactions = this.reactions(db, row.id), buttons = row.author_kind === "agent" ? this.buttons.view(db, row.id, id => this.memberName(db, id)) : undefined;
|
|
324
|
-
return { ...(lapsed ? { reasonCode: "share-needs-reshare" } : {}), ...(missing ? { reasonCode: "finished-without-answer" } : {}), ...(stopped ? { reasonCode: "owner-stopped-sharing" } : {}), ...(ask ? { ask } : {}), ...(asker ? { askedBy: asker.id } : {}), ...(this.assistant.warning(db, row.id) ? { warning: "assistant-unavailable" } : {}), ...(reactions.length ? { reactions } : {}), ...(buttons ? { buttons } : {}) };
|
|
330
|
+
return { ...(reactionAck ? { acknowledgedByReaction: true } : {}), ...(lapsed ? { reasonCode: "share-needs-reshare" } : {}), ...(missing ? { reasonCode: "finished-without-answer" } : {}), ...(stopped ? { reasonCode: "owner-stopped-sharing" } : {}), ...(ask ? { ask } : {}), ...(asker ? { askedBy: asker.id } : {}), ...(this.assistant.warning(db, row.id) ? { warning: "assistant-unavailable" } : {}), ...(reactions.length ? { reactions } : {}), ...(buttons ? { buttons } : {}) };
|
|
325
331
|
}) };
|
|
326
332
|
}
|
|
327
333
|
/** M-3127: a post's reactions, each emoji in the order it first appeared, its members in the order they reacted. */
|
|
@@ -682,23 +688,70 @@ export class HubGroupRooms {
|
|
|
682
688
|
db.prepare("INSERT INTO hub_room_members(id,room_id,kind,subject,role,joined_sequence) VALUES(?,?,'person',?,'member',0)").run(randomUUID(), id, me);
|
|
683
689
|
this.addAssistant(db, id);
|
|
684
690
|
}
|
|
691
|
+
async creationHint(ctx, me) {
|
|
692
|
+
const provider = this.core.deps.roomCreation;
|
|
693
|
+
if (!provider || this.core.atomic(db => canCreateRoom(this.core, db, me)))
|
|
694
|
+
return false;
|
|
695
|
+
const actor = await ctx.current();
|
|
696
|
+
if (actor.kind !== "directory" || personKeyString(actor.person) !== me)
|
|
697
|
+
return false;
|
|
698
|
+
const assertSession = () => {
|
|
699
|
+
this.fence(ctx).assertCurrent();
|
|
700
|
+
if (ctx.isIdentityCurrent?.(actor.person, actor.sessionId) !== true)
|
|
701
|
+
throw new HubProtocolError("revoked");
|
|
702
|
+
};
|
|
703
|
+
assertSession();
|
|
704
|
+
const wall = this.core.now(), elapsed = performance.now();
|
|
705
|
+
const valid = (hint) => hint.provider === provider && wall >= hint.wall && wall < hint.wall + ROOM_CREATION_HINT_MS
|
|
706
|
+
&& elapsed >= hint.elapsed && elapsed < hint.elapsed + ROOM_CREATION_HINT_MS;
|
|
707
|
+
for (const [key, hint] of this.creationHints)
|
|
708
|
+
if (!valid(hint))
|
|
709
|
+
this.creationHints.delete(key);
|
|
710
|
+
const key = JSON.stringify([me, actor.sessionId, ctx.application?.id ?? null]);
|
|
711
|
+
let hint = this.creationHints.get(key);
|
|
712
|
+
if (!hint) {
|
|
713
|
+
const value = (async () => {
|
|
714
|
+
try {
|
|
715
|
+
const access = await prepareRoomCreation(this.core, ctx, me);
|
|
716
|
+
return this.core.atomic(db => access.allows(db));
|
|
717
|
+
}
|
|
718
|
+
catch {
|
|
719
|
+
return false;
|
|
720
|
+
} // An unavailable display hint never narrows membership reads.
|
|
721
|
+
})();
|
|
722
|
+
hint = { wall, elapsed, provider, value };
|
|
723
|
+
if (this.creationHints.size >= ROOM_CREATION_HINT_LIMIT)
|
|
724
|
+
this.creationHints.delete(this.creationHints.keys().next().value);
|
|
725
|
+
this.creationHints.set(key, hint);
|
|
726
|
+
}
|
|
727
|
+
const result = await hint.value;
|
|
728
|
+
assertSession();
|
|
729
|
+
return result;
|
|
730
|
+
}
|
|
685
731
|
async list(ctx) {
|
|
686
732
|
const me = await this.who(ctx);
|
|
733
|
+
let roleHint = false;
|
|
734
|
+
try {
|
|
735
|
+
roleHint = await this.creationHint(ctx, me);
|
|
736
|
+
}
|
|
737
|
+
catch { /* Membership/session read retains its own fence. */ }
|
|
687
738
|
this.agents.sweep();
|
|
688
739
|
return this.core.atomic(db => {
|
|
689
740
|
if (!ctx.application)
|
|
690
741
|
this.assistantRoom(db, me);
|
|
742
|
+
let canCreateRooms = canCreateRoom(this.core, db, me);
|
|
743
|
+
canCreateRooms ||= roleHint;
|
|
691
744
|
return { rooms: db.prepare("SELECT * FROM hub_room_members WHERE kind='person' AND subject=?").all(me)
|
|
692
745
|
.map(m => this.summary(db, this.room(db, m.room_id), m)).sort((a, b) => b.lastAt - a.lastAt),
|
|
693
|
-
me: { canCreateRooms
|
|
746
|
+
me: { canCreateRooms, assistant: this.assistant.availability()?.enabled === true }, invitations: 0 };
|
|
694
747
|
}, this.fence(ctx));
|
|
695
748
|
}
|
|
696
749
|
async candidates(ctx, q, kind, discovery = false) {
|
|
697
750
|
if (q.length > 64 || /[\u0000-\u001f\u007f]/.test(q) || !["person", "team", "group", "agent"].includes(kind))
|
|
698
751
|
throw new HubProtocolError("invalid");
|
|
699
|
-
const me = await this.who(ctx)
|
|
700
|
-
|
|
701
|
-
|
|
752
|
+
const me = await this.who(ctx), access = await prepareRoomCreation(this.core, ctx, me, db => !!db.prepare(`SELECT 1 FROM hub_room_members m JOIN hub_group_rooms r ON r.id=m.room_id
|
|
753
|
+
WHERE m.kind='person' AND m.subject=? AND m.role='manager' AND r.archived=0`).get(me));
|
|
754
|
+
const allowed = access.allows;
|
|
702
755
|
if (kind === "agent") {
|
|
703
756
|
this.core.atomic(db => { if (!allowed(db))
|
|
704
757
|
throw new HubRoomRefusal(403, "denied"); }, this.fence(ctx));
|
|
@@ -743,16 +796,15 @@ export class HubGroupRooms {
|
|
|
743
796
|
return kind === "team" ? (this.core.deps.roomTeamCandidates?.(db, q.trim()) ?? []).slice(0, 20).map(row => ({ kind: "team", ...row })) : roomPersonLabels(hits);
|
|
744
797
|
}, this.fence(ctx));
|
|
745
798
|
}
|
|
746
|
-
|
|
747
|
-
this.core
|
|
748
|
-
|
|
749
|
-
WHERE m.kind='person' AND m.subject=? AND m.role='manager' AND r.archived=0 AND r.assistant_for IS NULL`).get(me))
|
|
750
|
-
throw new HubRoomRefusal(403, "denied");
|
|
751
|
-
}, this.fence(ctx));
|
|
799
|
+
candidateAccess(ctx, me) {
|
|
800
|
+
return prepareRoomCreation(this.core, ctx, me, db => !!db.prepare(`SELECT 1 FROM hub_room_members m JOIN hub_group_rooms r ON r.id=m.room_id
|
|
801
|
+
WHERE m.kind='person' AND m.subject=? AND m.role='manager' AND r.archived=0 AND r.assistant_for IS NULL`).get(me));
|
|
752
802
|
}
|
|
753
|
-
async groupSelection(ctx, me, id) {
|
|
803
|
+
async groupSelection(ctx, me, id, prepared) {
|
|
804
|
+
const access = prepared ?? await this.candidateAccess(ctx, me);
|
|
805
|
+
const assertCurrent = () => { this.fence(ctx).assertCurrent(); access.assertCurrent(); };
|
|
754
806
|
try {
|
|
755
|
-
return await this.directory.roster(ctx, me, id,
|
|
807
|
+
return await this.directory.roster(ctx, me, id, assertCurrent);
|
|
756
808
|
}
|
|
757
809
|
catch (e) {
|
|
758
810
|
if (e instanceof HubRoomRefusal || e instanceof HubProtocolError && ["revoked", "denied", "backpressure"].includes(e.code))
|
|
@@ -765,9 +817,8 @@ export class HubGroupRooms {
|
|
|
765
817
|
return { kind: "group", id, name: selection.name, people: selection.people.length };
|
|
766
818
|
}
|
|
767
819
|
async create(ctx, input) {
|
|
768
|
-
const body = validated(createSchema, input), me = await this.who(ctx);
|
|
769
|
-
|
|
770
|
-
throw new HubRoomRefusal(403, "denied"); }, this.fence(ctx));
|
|
820
|
+
const body = validated(createSchema, input), me = await this.who(ctx), access = await prepareRoomCreation(this.core, ctx, me);
|
|
821
|
+
access.assertCurrent();
|
|
771
822
|
const teams = this.core.deps.roomTeams;
|
|
772
823
|
const expansion = (db) => {
|
|
773
824
|
if (!body.teams.length)
|
|
@@ -782,7 +833,7 @@ export class HubGroupRooms {
|
|
|
782
833
|
const selected = this.core.atomic(expansion), image = JSON.stringify(selected);
|
|
783
834
|
const groupPeople = [];
|
|
784
835
|
for (const group of new Set(body.groups))
|
|
785
|
-
groupPeople.push(...(await this.groupSelection(ctx, me, group)).people.map(p => p.id));
|
|
836
|
+
groupPeople.push(...(await this.groupSelection(ctx, me, group, access)).people.map(p => p.id));
|
|
786
837
|
const people = [...new Set([me, ...body.people, ...selected.people, ...groupPeople])];
|
|
787
838
|
if (people.length > 100)
|
|
788
839
|
throw new HubRoomRefusal(409, "people-limit", { people: people.length, limit: 100 });
|
|
@@ -800,7 +851,7 @@ export class HubGroupRooms {
|
|
|
800
851
|
permit.assertCurrent();
|
|
801
852
|
if (JSON.stringify(expansion(db)) !== image)
|
|
802
853
|
throw new HubProtocolError("conflict");
|
|
803
|
-
if (!
|
|
854
|
+
if (!access.allows(db))
|
|
804
855
|
throw new HubRoomRefusal(403, "denied");
|
|
805
856
|
rememberRoomPeople(db, selectedPeople, this.core.now());
|
|
806
857
|
const id = randomUUID();
|
|
@@ -816,7 +867,7 @@ export class HubGroupRooms {
|
|
|
816
867
|
this.recordPurpose(db, tx, id, me, body.purpose, ctx.requestId);
|
|
817
868
|
this.core.audit(tx, { requestId: ctx.requestId, actor: { kind: "person", person: personFromString(me) }, action: "room.created", result: "completed", roomId: id });
|
|
818
869
|
return this.summary(db, this.room(db, id), this.member(db, id, me));
|
|
819
|
-
}, { assertCurrent: () => { this.fence(ctx).assertCurrent(); for (const permit of permits)
|
|
870
|
+
}, { assertCurrent: () => { this.fence(ctx).assertCurrent(); access.assertCurrent(); for (const permit of permits)
|
|
820
871
|
permit.assertCurrent(); } });
|
|
821
872
|
this.emit({ type: "room.changed", roomId: room.id, data: { roomId: room.id } });
|
|
822
873
|
return { room };
|
|
@@ -1426,7 +1477,7 @@ export class HubGroupRooms {
|
|
|
1426
1477
|
throw new HubProtocolError("invalid");
|
|
1427
1478
|
if (!link.current() || !link.features.has(HUB_ROOM_REACT_CAPABILITY))
|
|
1428
1479
|
throw new HubProtocolError("revoked");
|
|
1429
|
-
const
|
|
1480
|
+
const apply = (db) => {
|
|
1430
1481
|
const d = db.prepare("SELECT * FROM hub_room_deliveries WHERE id=?").get(body.messageId);
|
|
1431
1482
|
if (!d || d.fleet_id !== link.fleetId || d.owner !== personKeyString(link.owner) || d.room_id !== body.roomId || d.exposure_id !== body.exposureId)
|
|
1432
1483
|
throw new HubProtocolError("denied");
|
|
@@ -1451,12 +1502,13 @@ export class HubGroupRooms {
|
|
|
1451
1502
|
if (body.emoji)
|
|
1452
1503
|
db.prepare("INSERT INTO hub_room_reactions(room_id,post_id,member_id,emoji,created_at) VALUES(?,?,?,?,?)").run(d.room_id, post.id, who, body.emoji, this.core.now());
|
|
1453
1504
|
return { post, changed: true };
|
|
1454
|
-
}
|
|
1505
|
+
};
|
|
1506
|
+
const done = body.acknowledge ? await this.agents.acknowledgeReaction(body, link, apply) : this.core.atomic(apply);
|
|
1455
1507
|
if ("archived" in done)
|
|
1456
1508
|
return { messageId: body.messageId, ok: false, code: "archived" };
|
|
1457
1509
|
if (done.changed && done.post)
|
|
1458
1510
|
this.emit({ type: "message.updated", roomId: done.post.room_id, data: { roomId: done.post.room_id, message: this.projection(done.post) }, sequence: done.post.sequence });
|
|
1459
|
-
return { messageId: body.messageId, ok: true };
|
|
1511
|
+
return { messageId: body.messageId, ok: true, ...(body.acknowledge ? { acknowledged: true } : {}) };
|
|
1460
1512
|
}
|
|
1461
1513
|
/** A read or a press first closes what is already due (a suspended host's timer may be late): never a stale open poll. */
|
|
1462
1514
|
settleButtons() {
|