( serverThreadInfo: ServerThreadInfo, viewerID: string, options?: RawThreadInfoOptions, )
| 674 | }; |
| 675 | |
| 676 | function rawThreadInfoFromServerThreadInfo( |
| 677 | serverThreadInfo: ServerThreadInfo, |
| 678 | viewerID: string, |
| 679 | options?: RawThreadInfoOptions, |
| 680 | ): ?LegacyThinRawThreadInfo | ?ThinRawThreadInfo { |
| 681 | const filterThreadEditAvatarPermission = |
| 682 | options?.filterThreadEditAvatarPermission; |
| 683 | const excludePinInfo = options?.excludePinInfo; |
| 684 | const filterManageInviteLinksPermission = |
| 685 | options?.filterManageInviteLinksPermission; |
| 686 | const filterVoicedInAnnouncementChannelsPermission = |
| 687 | options?.filterVoicedInAnnouncementChannelsPermission; |
| 688 | const shouldMinimallyEncodePermissions = options?.minimallyEncodePermissions; |
| 689 | const shouldIncludeSpecialRoleFieldInRoles = |
| 690 | options?.includeSpecialRoleFieldInRoles; |
| 691 | const allowAddingUsersToCommunityRoot = |
| 692 | options?.allowAddingUsersToCommunityRoot; |
| 693 | const filterManageFarcasterChannelTagsPermission = |
| 694 | options?.filterManageFarcasterChannelTagsPermission; |
| 695 | const stripMemberPermissions = options?.stripMemberPermissions; |
| 696 | const canDisplayFarcasterThreadAvatars = |
| 697 | options?.canDisplayFarcasterThreadAvatars; |
| 698 | const dontFilterMissingKnowOf = options?.dontFilterMissingKnowOf ?? false; |
| 699 | const filterDeleteMessagePermissions = options?.messageDeletionUnsupported; |
| 700 | |
| 701 | const filterThreadPermissions = ( |
| 702 | innerThreadPermissions: ThreadPermissionsInfo, |
| 703 | ) => { |
| 704 | if ( |
| 705 | allowAddingUsersToCommunityRoot && |
| 706 | (serverThreadInfo.type === threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT || |
| 707 | serverThreadInfo.type === threadTypes.COMMUNITY_ROOT) |
| 708 | ) { |
| 709 | innerThreadPermissions = { |
| 710 | ...innerThreadPermissions, |
| 711 | [threadPermissions.ADD_MEMBERS]: { |
| 712 | value: true, |
| 713 | source: serverThreadInfo.id, |
| 714 | }, |
| 715 | }; |
| 716 | } |
| 717 | return _omitBy( |
| 718 | (v, k) => |
| 719 | (filterThreadEditAvatarPermission && |
| 720 | [ |
| 721 | threadPermissions.EDIT_THREAD_AVATAR, |
| 722 | threadPermissionPropagationPrefixes.DESCENDANT + |
| 723 | threadPermissions.EDIT_THREAD_AVATAR, |
| 724 | ].includes(k)) || |
| 725 | (excludePinInfo && |
| 726 | [ |
| 727 | threadPermissions.MANAGE_PINS, |
| 728 | threadPermissionPropagationPrefixes.DESCENDANT + |
| 729 | threadPermissions.MANAGE_PINS, |
| 730 | ].includes(k)) || |
| 731 | (filterManageInviteLinksPermission && |
| 732 | [threadPermissions.MANAGE_INVITE_LINKS].includes(k)) || |
| 733 | (filterVoicedInAnnouncementChannelsPermission && |
no test coverage detected