@rmdes/indiekit-endpoint-activitypub 2.0.13 → 2.0.15

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/index.js CHANGED
@@ -950,6 +950,10 @@ export default class ActivityPubEndpoint {
950
950
  );
951
951
  }
952
952
 
953
+ // Drop non-sparse indexes if they exist (created by earlier versions),
954
+ // then recreate with sparse:true so multiple null values are allowed.
955
+ try { await this._collections.ap_muted.dropIndex("url_1"); } catch {}
956
+ try { await this._collections.ap_muted.dropIndex("keyword_1"); } catch {}
953
957
  this._collections.ap_muted.createIndex(
954
958
  { url: 1 },
955
959
  { unique: true, sparse: true, background: true },
@@ -126,7 +126,10 @@ export function readerController(mountPath) {
126
126
  item._moderated = true;
127
127
  item._moderationReason = isMutedActor
128
128
  ? "muted_account"
129
- : `muted_keyword:${matchedKeyword}`;
129
+ : "muted_keyword";
130
+ if (matchedKeyword) {
131
+ item._moderationKeyword = matchedKeyword;
132
+ }
130
133
  return true;
131
134
  }
132
135
  return false;
@@ -22,11 +22,11 @@ export async function addMuted(collections, { url, keyword }) {
22
22
  throw new Error("Cannot mute both url and keyword in same entry");
23
23
  }
24
24
 
25
- const entry = {
26
- url: url || null,
27
- keyword: keyword || null,
28
- mutedAt: new Date().toISOString(),
29
- };
25
+ // Only include the field that's set — avoids null values that conflict
26
+ // with sparse unique indexes
27
+ const entry = { mutedAt: new Date().toISOString() };
28
+ if (url) entry.url = url;
29
+ if (keyword) entry.keyword = keyword;
30
30
 
31
31
  // Upsert to avoid duplicates
32
32
  const filter = url ? { url } : { keyword };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
5
5
  "keywords": [
6
6
  "indiekit",
@@ -9,11 +9,10 @@
9
9
  <article class="ap-card{% if item.type %} ap-card--{{ item.type }}{% endif %}{% if item.inReplyTo %} ap-card--reply{% endif %}{% if item._moderated %} ap-card--moderated{% endif %}">
10
10
  {# Moderation content warning wrapper #}
11
11
  {% if item._moderated %}
12
- {% set modReason = item._moderationReason %}
13
- {% if modReason == "muted_account" %}
12
+ {% if item._moderationReason == "muted_account" %}
14
13
  {% set modLabel = __("activitypub.moderation.cwMutedAccount") %}
15
- {% elif modReason.startsWith("muted_keyword:") %}
16
- {% set modLabel = __("activitypub.moderation.cwMutedKeyword") + " \"" + modReason.replace("muted_keyword:", "") + "\"" %}
14
+ {% elif item._moderationReason == "muted_keyword" and item._moderationKeyword %}
15
+ {% set modLabel = __("activitypub.moderation.cwMutedKeyword") + ' "' + item._moderationKeyword + '"' %}
17
16
  {% else %}
18
17
  {% set modLabel = __("activitypub.moderation.cwFiltered") %}
19
18
  {% endif %}
@@ -201,6 +200,11 @@
201
200
  </a>
202
201
  <div x-show="error" x-text="error" class="ap-card__action-error" x-transition></div>
203
202
  </footer>
203
+ {# Close moderation content warning wrapper #}
204
+ {% if item._moderated %}
205
+ </div>{# /x-show="shown" #}
206
+ </div>{# /ap-card__moderation-cw #}
207
+ {% endif %}
204
208
  </article>
205
209
 
206
210
  {% endif %}{# end hasCardContent/hasCardTitle/hasCardMedia guard #}