@rmdes/indiekit-endpoint-webmention-io 1.0.1 → 1.0.3

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.
@@ -19,12 +19,7 @@ export const blocklistController = {
19
19
  if (db) {
20
20
  const collection = db.collection("webmentionBlocklist");
21
21
  const raw = await getBlocklist(collection);
22
- entries = raw.map((entry) => ({
23
- ...entry,
24
- blockedAt: entry.blockedAt instanceof Date
25
- ? entry.blockedAt.toISOString()
26
- : entry.blockedAt,
27
- }));
22
+ entries = raw;
28
23
  }
29
24
 
30
25
  response.render("webmentions-blocklist", {
@@ -15,17 +15,6 @@ import { blockDomain } from "../storage/blocklist.js";
15
15
  import { getSyncState } from "../sync.js";
16
16
  import { getMentionType, getMentionTitle, getAuthorName } from "../utils.js";
17
17
 
18
- /**
19
- * Convert Date objects to ISO strings for Nunjucks date filter
20
- * @param {*} value
21
- * @returns {string|undefined}
22
- */
23
- function toDateString(value) {
24
- if (!value) return undefined;
25
- if (value instanceof Date) return value.toISOString();
26
- return String(value);
27
- }
28
-
29
18
  export const dashboardController = {
30
19
  /**
31
20
  * GET / - Webmentions dashboard
@@ -40,10 +29,7 @@ export const dashboardController = {
40
29
  title: response.locals.__("webmention-io.title"),
41
30
  webmentions: [],
42
31
  counts: { total: 0, hidden: 0, visible: 0 },
43
- syncState: {
44
- ...getSyncState(),
45
- lastSync: toDateString(getSyncState().lastSync),
46
- },
32
+ syncState: getSyncState(),
47
33
  cursor: {},
48
34
  filter: "all",
49
35
  typeFilter: "all",
@@ -96,7 +82,7 @@ export const dashboardController = {
96
82
  locale: application.locale,
97
83
  title: getMentionTitle({ name: item.name, "wm-property": item.wmProperty }),
98
84
  description: html ? { html } : undefined,
99
- published: toDateString(item.published || item.wmReceived),
85
+ published: item.published || item.wmReceived,
100
86
  url: item.sourceUrl,
101
87
  user: {
102
88
  avatar: { src: item.authorPhoto },
@@ -125,10 +111,7 @@ export const dashboardController = {
125
111
  title: response.locals.__("webmention-io.title"),
126
112
  webmentions,
127
113
  counts,
128
- syncState: {
129
- ...getSyncState(),
130
- lastSync: toDateString(getSyncState().lastSync),
131
- },
114
+ syncState: getSyncState(),
132
115
  cursor,
133
116
  filter,
134
117
  typeFilter,
@@ -23,7 +23,7 @@ export async function blockDomain(collection, domain, reason = "spam", mentionsH
23
23
  await collection.insertOne({
24
24
  domain,
25
25
  reason,
26
- blockedAt: new Date(),
26
+ blockedAt: new Date().toISOString(),
27
27
  mentionsHidden,
28
28
  });
29
29
  return true;
@@ -36,7 +36,7 @@ export function jf2ToDocument(item) {
36
36
 
37
37
  return {
38
38
  wmId: item["wm-id"],
39
- wmReceived: item["wm-received"] ? new Date(item["wm-received"]) : new Date(),
39
+ wmReceived: item["wm-received"] || new Date().toISOString(),
40
40
  wmProperty: item["wm-property"],
41
41
  wmTarget: item["wm-target"],
42
42
  authorName: item.author?.name || null,
@@ -44,14 +44,14 @@ export function jf2ToDocument(item) {
44
44
  authorPhoto: item.author?.photo || null,
45
45
  sourceUrl: item.url || null,
46
46
  sourceDomain: extractDomain(item.author?.url || item.url || ""),
47
- published: item.published ? new Date(item.published) : null,
47
+ published: item.published || null,
48
48
  contentHtml,
49
49
  contentText,
50
50
  name: item.name || null,
51
51
  hidden: false,
52
52
  hiddenAt: null,
53
53
  hiddenReason: null,
54
- syncedAt: new Date(),
54
+ syncedAt: new Date().toISOString(),
55
55
  raw: item,
56
56
  };
57
57
  }
@@ -65,7 +65,7 @@ export function documentToJf2(doc) {
65
65
  const jf2 = {
66
66
  type: "entry",
67
67
  "wm-id": doc.wmId,
68
- "wm-received": doc.wmReceived?.toISOString?.() || doc.wmReceived,
68
+ "wm-received": doc.wmReceived,
69
69
  "wm-property": doc.wmProperty,
70
70
  "wm-target": doc.wmTarget,
71
71
  author: {
@@ -75,7 +75,7 @@ export function documentToJf2(doc) {
75
75
  photo: doc.authorPhoto || "",
76
76
  },
77
77
  url: doc.sourceUrl || "",
78
- published: doc.published?.toISOString?.() || doc.published || doc.wmReceived,
78
+ published: doc.published || doc.wmReceived,
79
79
  };
80
80
 
81
81
  if (doc.name) {
@@ -185,7 +185,7 @@ export async function getMaxWmId(collection) {
185
185
  export async function hideWebmention(collection, wmId, reason = "manual") {
186
186
  await collection.updateOne(
187
187
  { wmId },
188
- { $set: { hidden: true, hiddenAt: new Date(), hiddenReason: reason } },
188
+ { $set: { hidden: true, hiddenAt: new Date().toISOString(), hiddenReason: reason } },
189
189
  );
190
190
  }
191
191
 
@@ -211,7 +211,7 @@ export async function unhideWebmention(collection, wmId) {
211
211
  export async function hideByDomain(collection, domain, reason = "blocklist") {
212
212
  const result = await collection.updateMany(
213
213
  { sourceDomain: domain, hidden: { $ne: true } },
214
- { $set: { hidden: true, hiddenAt: new Date(), hiddenReason: reason } },
214
+ { $set: { hidden: true, hiddenAt: new Date().toISOString(), hiddenReason: reason } },
215
215
  );
216
216
  return result.modifiedCount;
217
217
  }
package/lib/sync.js CHANGED
@@ -141,7 +141,7 @@ export async function runSync(dbOrIndiekit, options) {
141
141
  }
142
142
  }
143
143
 
144
- syncState.lastSync = new Date();
144
+ syncState.lastSync = new Date().toISOString();
145
145
  syncState.syncing = false;
146
146
 
147
147
  console.log(
@@ -232,7 +232,7 @@ export async function runFullSync(dbOrIndiekit, options) {
232
232
  }
233
233
  }
234
234
 
235
- syncState.lastSync = new Date();
235
+ syncState.lastSync = new Date().toISOString();
236
236
  syncState.syncing = false;
237
237
 
238
238
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-webmention-io",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Webmention moderation endpoint for Indiekit. Syncs webmentions from webmention.io into MongoDB with delete, block, and privacy removal capabilities.",
5
5
  "keywords": [
6
6
  "indiekit",
@@ -32,21 +32,6 @@
32
32
  min-width: 200px;
33
33
  }
34
34
 
35
- .bl-form .field__label {
36
- display: block;
37
- font: var(--font-caption, 0.75rem/1.4 sans-serif);
38
- font-weight: 600;
39
- margin-block-end: 0.25rem;
40
- }
41
-
42
- .bl-form .field__input {
43
- width: 100%;
44
- padding: var(--space-2xs, 0.375rem) var(--space-xs, 0.5rem);
45
- border: 1px solid var(--color-outline-variant, #ccc);
46
- border-radius: var(--border-radius-small, 0.25rem);
47
- font: var(--font-body, 0.875rem/1.5 sans-serif);
48
- }
49
-
50
35
  .bl-table {
51
36
  width: 100%;
52
37
  border-collapse: collapse;
@@ -126,8 +111,8 @@
126
111
 
127
112
  <form method="post" action="{{ wmEndpoint }}/block" class="bl-form">
128
113
  <div class="field">
129
- <label class="field__label">{{ __("webmention-io.blocklist.domainLabel") }}</label>
130
- <input type="text" name="domain" class="field__input" placeholder="{{ __("webmention-io.blocklist.domainPlaceholder") }}" required>
114
+ <label class="label">{{ __("webmention-io.blocklist.domainLabel") }}</label>
115
+ <input type="text" name="domain" class="input" placeholder="{{ __("webmention-io.blocklist.domainPlaceholder") }}" required>
131
116
  </div>
132
117
  <button type="submit" class="button button--primary">{{ __("webmention-io.blocklist.blockButton") }}</button>
133
118
  </form>
@@ -141,8 +126,8 @@
141
126
  <form method="post" action="{{ wmEndpoint }}/privacy-remove" class="bl-form"
142
127
  onsubmit="return confirm('This will PERMANENTLY DELETE all webmentions from this domain and block it. This cannot be undone. Continue?')">
143
128
  <div class="field">
144
- <label class="field__label">{{ __("webmention-io.blocklist.privacy.domainLabel") }}</label>
145
- <input type="text" name="domain" class="field__input" placeholder="{{ __("webmention-io.blocklist.domainPlaceholder") }}" required>
129
+ <label class="label">{{ __("webmention-io.blocklist.privacy.domainLabel") }}</label>
130
+ <input type="text" name="domain" class="input" placeholder="{{ __("webmention-io.blocklist.domainPlaceholder") }}" required>
146
131
  </div>
147
132
  <button type="submit" class="button button--primary">{{ __("webmention-io.blocklist.privacy.removeButton") }}</button>
148
133
  </form>
@@ -173,7 +158,7 @@
173
158
  </span>
174
159
  </td>
175
160
  <td>{{ entry.mentionsHidden or 0 }}</td>
176
- <td>{{ entry.blockedAt | date }}</td>
161
+ <td>{{ entry.blockedAt | date("PPp") }}</td>
177
162
  <td>
178
163
  <form method="post" action="{{ wmEndpoint }}/blocklist/{{ entry.domain | urlencode }}/delete" style="display:inline">
179
164
  <button type="submit" class="button button--small button--secondary"
@@ -139,7 +139,7 @@
139
139
  <div class="wm-actions-bar">
140
140
  <span class="wm-sync-info">
141
141
  {% if syncState.lastSync %}
142
- {{ __("webmention-io.sync.lastSync") }}: {{ syncState.lastSync | date }}
142
+ {{ __("webmention-io.sync.lastSync") }}: {{ syncState.lastSync | date("PPp") }}
143
143
  {% else %}
144
144
  {{ __("webmention-io.sync.never") }}
145
145
  {% endif %}