Skip to content

Commit

Permalink
👍 outboxエンドポイントを追加してActorにoutboxを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
haruyuki-16278 committed Feb 26, 2024
1 parent bf33659 commit 2c12159
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as $reset from "./routes/reset.ts";
import * as $u_event_followers from "./routes/u/event/followers.ts";
import * as $u_event_inbox from "./routes/u/event/inbox.ts";
import * as $u_event_index from "./routes/u/event/index.ts";
import * as $u_event_outbox from "./routes/u/event/outbox.ts";
import * as $CopyToClipboard from "./islands/CopyToClipboard.tsx";
import * as $Counter from "./islands/Counter.tsx";
import * as $EventCard from "./islands/EventCard.tsx";
Expand All @@ -38,6 +39,7 @@ const manifest = {
"./routes/u/event/followers.ts": $u_event_followers,
"./routes/u/event/inbox.ts": $u_event_inbox,
"./routes/u/event/index.ts": $u_event_index,
"./routes/u/event/outbox.ts": $u_event_outbox,
},
islands: {
"./islands/CopyToClipboard.tsx": $CopyToClipboard,
Expand Down
1 change: 1 addition & 0 deletions routes/u/event/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const handler: Handlers = {
"type": "Person",
"discoverable": true,
"inbox": `${entrypoint}u/event/inbox`,
"outbox": `${entrypoint}u/event/outbox`,
"followers": `${entrypoint}u/event/followers`,
"preferredUsername": "たまイベント",
"name": "たまイベント",
Expand Down
20 changes: 20 additions & 0 deletions routes/u/event/outbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Handlers } from "$fresh/server.ts";
import { entrypoint } from "../../../const.ts";
import { EventItem } from "../../../interface/EventItem.interface.ts";
import { kv } from "../../../kv.ts";

export const handler: Handlers = {
async GET(_req, _ctx) {
const list = await kv.list<EventItem>({ prefix: ["eventItems"] });
let eventCount = 0;
for await (const item of list) {
if (!item.value.permitted) continue;
eventCount++;
}
return Response.json({
"@context": "https://www.w3.org/ns/activitystreams",
"id": `${entrypoint}u/event/outbox`,
"totalItems": eventCount,
});
},
};

0 comments on commit 2c12159

Please sign in to comment.