domma-cms 1.28.3 → 1.28.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.28.4] - 2026-11-01
4
+
5
+ - Games: the goes-per-name limit can no longer be beaten by starting several goes at once under one name. The shared Games library now counts a name's goes in the same turn that saves the new go (`PlayStore.start(play, {maxGoes})`), where before two starts sent together could both pass the check. Quiz 1.6.1, Crossword 1.5.1 and Word Search 1.2.1 use it.
6
+
3
7
  ## [1.28.3] - 2026-11-01
4
8
 
5
9
  - Site repos: visitor chats (sessions, messages and unanswered questions), Games plays (player names and resume tokens) and outreach records (contacts, the do-not-email list, Campaigns sends, claims and opens) are kept out of a site's git repo, like form submissions and orders already were. The chat Knowledge and outreach groups are authored and stay tracked.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.28.3",
3
+ "version": "1.28.4",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -10,7 +10,9 @@
10
10
  * leaves the server again - not to the board, not to the admin.
11
11
  *
12
12
  * Writes go one at a time (`withLock`), so two answers sent at once cannot
13
- * both be marked.
13
+ * both be marked. The goes-per-name limit is checked inside that same turn
14
+ * (`start(play, {maxGoes})`), so two starts sent at once under one name cannot
15
+ * both slip under it.
14
16
  *
15
17
  * An ARCHIVE play (`archive: true`) is a go at a game rotation has closed
16
18
  * (_lib/games/rotation.js): played and timed like any other, listed for the
@@ -100,10 +102,20 @@ export class PlayStore {
100
102
  /**
101
103
  * @param {{gameId: string, name: string, maxScore?: number, state?: object, userId?: string, test?: boolean}} play
102
104
  * `test`: an admin trying the game; `archive`: a go at a game rotation has closed - see the module comment
103
- * @returns {Promise<object>} the play, token included - for the player, once
105
+ * @param {{maxGoes?: number, countGoes?: () => Promise<number>}} [limit] - `maxGoes` (0 = no limit) is how many
106
+ * goes this name may have; it is counted in the write turn, so starts sent at once cannot both get under it.
107
+ * `countGoes` counts differently (say, goes today); by default `attemptsBy(gameId, name)`. Test and archive
108
+ * plays are never limited.
109
+ * @returns {Promise<object|null>} the play, token included - for the player, once; null when the name has had
110
+ * its goes
104
111
  */
105
- async start({gameId, name, maxScore = 0, state = {}, userId = '', test = false, archive = false}) {
112
+ async start({gameId, name, maxScore = 0, state = {}, userId = '', test = false, archive = false}, {maxGoes = 0, countGoes} = {}) {
106
113
  return this.withLock(async () => {
114
+ if (maxGoes > 0 && !test && !archive) {
115
+ this.forget();
116
+ const had = countGoes ? await countGoes() : await this.attemptsBy(gameId, name);
117
+ if (had >= maxGoes) return null;
118
+ }
107
119
  const now = new Date().toISOString();
108
120
  const saved = await createEntry(this.slug, {
109
121
  gameId, name, nameKey: nameKey(name), userId,