All files / app/features contentRefs.ts

100% Statements 10/10
50% Branches 1/2
100% Functions 7/7
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                  1080x 19x 90x 9x 115x 226x     545x         76x     76x      
import type { User } from "proto/api_pb";
import type { Discussion } from "proto/discussions_pb";
import type { Event } from "proto/events_pb";
import type { PhotoGalleryItem } from "proto/galleries_pb";
import type { Message } from "proto/messages_pb";
import type { PublicTrip } from "proto/public_trips_pb";
import type { Reply } from "proto/threads_pb";
 
// content_refs identify reported content to moderators, see //docs/content_ref.md
export const contentRefs = {
  profile: (user: User.AsObject) => `profile/${user.userId}`,
  chatMessage: (message: Message.AsObject) => `chat/message/${message.messageId}`,
  photo: (photo: PhotoGalleryItem.AsObject) => `photo/${photo.itemId}`,
  publicTrip: (trip: PublicTrip.AsObject) => `public_trip/${trip.tripId}`,
  event: (event: Event.AsObject) => `event/${event.eventId}`,
  // a comment is referenced by its own thread id, not the thread of the
  // discussion or event it hangs off
  comment: (comment: Reply.AsObject) => `comment/${comment.threadId}`,
  // a discussion belongs to either a community or a group; the proto oneof is
  // flattened into two numbers, so the unset one comes back as 0
  discussion: (discussion: Discussion.AsObject) => {
    const owner =
      discussion.ownerCommunityId !== 0
        ? `community/${discussion.ownerCommunityId}`
        : `group/${discussion.ownerGroupId}`;
    return `${owner}/discussion/${discussion.discussionId}`;
  },
};