-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
86 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export { runActionInstance, runInstancesForEvent } from "../_lib/runActionInstance"; | ||
export { runActionInstanceServerAction } from "../_lib/runActionInstanceServerAction"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"use server"; | ||
|
||
import { revalidateTag } from "next/cache"; | ||
|
||
import { db } from "~/kysely/database"; | ||
import { UsersId } from "~/kysely/types/public/Users"; | ||
import { getLoginData } from "~/lib/auth/loginData"; | ||
import { | ||
ActionInstanceRunResult, | ||
RunActionInstanceArgs, | ||
runActionInstance as runActionInstanceInner, | ||
} from "../_lib/runActionInstance"; | ||
|
||
export const runActionInstance = async function runActionInstance( | ||
args: Omit<RunActionInstanceArgs, "userId" | "event"> | ||
): Promise<ActionInstanceRunResult> { | ||
const user = await getLoginData(); | ||
|
||
if (!user) { | ||
return { | ||
error: "Not logged in", | ||
}; | ||
} | ||
|
||
// Retrieve the pub's community id in order to revalidate the next server | ||
// cache after the action is run. | ||
const pub = await db | ||
.selectFrom("pubs") | ||
.select(["community_id as communityId"]) | ||
.where("id", "=", args.pubId) | ||
.executeTakeFirst(); | ||
|
||
const result = await runActionInstanceInner({ | ||
...args, | ||
userId: user.id as UsersId, | ||
}); | ||
|
||
if (pub !== undefined) { | ||
// Because an action can move a pub to a different stage, we need to | ||
// revalidate the community stage cache. | ||
revalidateTag(`community-stages_${pub.communityId}`); | ||
// Revalidate the community action runs cache for the action activity table. | ||
revalidateTag(`community-action-runs_${pub.communityId}`); | ||
} | ||
|
||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { | ||
Activity, | ||
Calendar, | ||
BadgeCheck, | ||
Check, | ||
|