@openpeepshq/common 0.5.11 → 0.5.12

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.
@@ -322,6 +322,18 @@ export declare const participantIds: (post: Pick<PublicPost, "audience" | "profi
322
322
  export declare const isOneToOneDm: (post: Pick<PublicPost, "visibility" | "audience" | "profile"> & {
323
323
  creatorId?: string;
324
324
  }) => boolean;
325
+ /**
326
+ * A direct-message leave is the reply that leaveConversation posts: it
327
+ * replies to the thread's newest post and leaves the leaver out of the
328
+ * audience, so the thread stops reaching them. Replies created through
329
+ * the conversations endpoint always keep their author in the audience
330
+ * (the endpoint rejects posters who are no longer in the newest post's
331
+ * audience), so a reply whose audience lacks its author is only ever a
332
+ * leave — while a root post whose author is missing from the audience is
333
+ * just a message. Deliberately marker-free: leave posts must stay plain
334
+ * notes so they remain valid ActivityPub direct messages.
335
+ */
336
+ export declare const isConversationLeavePost: (post: Pick<PublicPost, "inReplyToId" | "audience" | "profile">) => boolean;
325
337
  export declare const isOneToOneWithBlocked: (post: Pick<PublicPost, "visibility" | "audience" | "profile"> & {
326
338
  creatorId?: string;
327
339
  }, viewer: {
@@ -521,6 +521,23 @@ export const participantIds = (post) => {
521
521
  };
522
522
  /** Direct message between exactly two participants. */
523
523
  export const isOneToOneDm = (post) => post.visibility === 'direct' && participantIds(post).size === 2;
524
+ /**
525
+ * A direct-message leave is the reply that leaveConversation posts: it
526
+ * replies to the thread's newest post and leaves the leaver out of the
527
+ * audience, so the thread stops reaching them. Replies created through
528
+ * the conversations endpoint always keep their author in the audience
529
+ * (the endpoint rejects posters who are no longer in the newest post's
530
+ * audience), so a reply whose audience lacks its author is only ever a
531
+ * leave — while a root post whose author is missing from the audience is
532
+ * just a message. Deliberately marker-free: leave posts must stay plain
533
+ * notes so they remain valid ActivityPub direct messages.
534
+ */
535
+ export const isConversationLeavePost = (post) => {
536
+ const authorId = post.profile?.id;
537
+ if (!post.inReplyToId || !authorId)
538
+ return false;
539
+ return !post.audience?.some((p) => p.id === authorId);
540
+ };
524
541
  export const isOneToOneWithBlocked = (post, viewer, blockedIds) => {
525
542
  if (!viewer || post.visibility !== 'direct')
526
543
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/common",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -855,6 +855,25 @@ export const isOneToOneDm = (
855
855
  },
856
856
  ): boolean => post.visibility === 'direct' && participantIds(post).size === 2;
857
857
 
858
+ /**
859
+ * A direct-message leave is the reply that leaveConversation posts: it
860
+ * replies to the thread's newest post and leaves the leaver out of the
861
+ * audience, so the thread stops reaching them. Replies created through
862
+ * the conversations endpoint always keep their author in the audience
863
+ * (the endpoint rejects posters who are no longer in the newest post's
864
+ * audience), so a reply whose audience lacks its author is only ever a
865
+ * leave — while a root post whose author is missing from the audience is
866
+ * just a message. Deliberately marker-free: leave posts must stay plain
867
+ * notes so they remain valid ActivityPub direct messages.
868
+ */
869
+ export const isConversationLeavePost = (
870
+ post: Pick<PublicPost, 'inReplyToId' | 'audience' | 'profile'>,
871
+ ): boolean => {
872
+ const authorId = post.profile?.id;
873
+ if (!post.inReplyToId || !authorId) return false;
874
+ return !post.audience?.some((p) => p.id === authorId);
875
+ };
876
+
858
877
  export const isOneToOneWithBlocked = (
859
878
  post: Pick<PublicPost, 'visibility' | 'audience' | 'profile'> & {
860
879
  creatorId?: string;