From afef1c0dbd4251842466de60a9fbbed1df3b2b69 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 19 Dec 2024 17:34:15 +0000 Subject: [PATCH 1/2] rm `moderatePost_wrapped` --- .eslintrc.js | 13 -------- src/lib/moderatePost_wrapped.ts | 31 ------------------- .../Messages/components/MessageInputEmbed.tsx | 2 +- src/state/queries/notifications/feed.ts | 2 +- src/state/queries/post-feed.ts | 2 +- src/state/queries/post-thread.ts | 2 +- src/state/queries/search-posts.ts | 2 +- src/view/com/post-thread/PostQuotes.tsx | 2 +- src/view/com/post-thread/PostThread.tsx | 7 +++-- src/view/com/post/Post.tsx | 2 +- src/view/com/util/post-embeds/QuoteEmbed.tsx | 2 +- 11 files changed, 13 insertions(+), 54 deletions(-) delete mode 100644 src/lib/moderatePost_wrapped.ts diff --git a/.eslintrc.js b/.eslintrc.js index 8f8383bcc7..5f302dfd9f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -80,19 +80,6 @@ module.exports = { ], 'simple-import-sort/exports': 'error', 'react-compiler/react-compiler': 'warn', - 'no-restricted-imports': [ - 'error', - { - paths: [ - { - name: '@atproto/api', - importNames: ['moderatePost'], - message: - 'Please use `moderatePost_wrapped` from `#/lib/moderatePost_wrapped` instead.', - }, - ], - }, - ], }, ignorePatterns: [ '**/__mocks__/*.ts', diff --git a/src/lib/moderatePost_wrapped.ts b/src/lib/moderatePost_wrapped.ts deleted file mode 100644 index f4c9d0aad2..0000000000 --- a/src/lib/moderatePost_wrapped.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable-next-line no-restricted-imports */ -import {BSKY_LABELER_DID, moderatePost} from '@atproto/api' - -type ModeratePost = typeof moderatePost -type Options = Parameters[1] - -export function moderatePost_wrapped( - subject: Parameters[0], - opts: Options, -) { - // HACK - // temporarily translate 'gore' into 'graphic-media' during the transition period - // can remove this in a few months - // -prf - translateOldLabels(subject) - - return moderatePost(subject, opts) -} - -function translateOldLabels(subject: Parameters[0]) { - if (subject.labels) { - for (const label of subject.labels) { - if ( - label.val === 'gore' && - (!label.src || label.src === BSKY_LABELER_DID) - ) { - label.val = 'graphic-media' - } - } - } -} diff --git a/src/screens/Messages/components/MessageInputEmbed.tsx b/src/screens/Messages/components/MessageInputEmbed.tsx index 6df0ef2fc8..b96d36c001 100644 --- a/src/screens/Messages/components/MessageInputEmbed.tsx +++ b/src/screens/Messages/components/MessageInputEmbed.tsx @@ -4,13 +4,13 @@ import { AppBskyFeedPost, AppBskyRichtextFacet, AtUri, + moderatePost, RichText as RichTextAPI, } from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {RouteProp, useNavigation, useRoute} from '@react-navigation/native' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {makeProfileLink} from '#/lib/routes/links' import {CommonNavigatorParams, NavigationProp} from '#/lib/routes/types' import { diff --git a/src/state/queries/notifications/feed.ts b/src/state/queries/notifications/feed.ts index 72100a6245..56ee645754 100644 --- a/src/state/queries/notifications/feed.ts +++ b/src/state/queries/notifications/feed.ts @@ -22,6 +22,7 @@ import { AppBskyFeedDefs, AppBskyFeedPost, AtUri, + moderatePost, } from '@atproto/api' import { InfiniteData, @@ -31,7 +32,6 @@ import { useQueryClient, } from '@tanstack/react-query' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {useAgent} from '#/state/session' import {useThreadgateHiddenReplyUris} from '#/state/threadgate-hidden-replies' import {useModerationOpts} from '../../preferences/moderation-opts' diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index 2eb604627e..4ed5385d43 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -6,6 +6,7 @@ import { AppBskyFeedPost, AtUri, BskyAgent, + moderatePost, ModerationDecision, } from '@atproto/api' import { @@ -27,7 +28,6 @@ import {aggregateUserInterests} from '#/lib/api/feed/utils' import {FeedTuner, FeedTunerFn} from '#/lib/api/feed-manip' import {DISCOVER_FEED_URI} from '#/lib/constants' import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {logger} from '#/logger' import {STALE} from '#/state/queries' import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const' diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts index 2ebaf4f7dc..c5f0906979 100644 --- a/src/state/queries/post-thread.ts +++ b/src/state/queries/post-thread.ts @@ -5,12 +5,12 @@ import { AppBskyFeedGetPostThread, AppBskyFeedPost, AtUri, + moderatePost, ModerationDecision, ModerationOpts, } from '@atproto/api' import {QueryClient, useQuery, useQueryClient} from '@tanstack/react-query' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes' import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types' import { diff --git a/src/state/queries/search-posts.ts b/src/state/queries/search-posts.ts index 8a8a3fa52f..5cac86f7f3 100644 --- a/src/state/queries/search-posts.ts +++ b/src/state/queries/search-posts.ts @@ -4,6 +4,7 @@ import { AppBskyFeedDefs, AppBskyFeedSearchPosts, AtUri, + moderatePost, } from '@atproto/api' import { InfiniteData, @@ -12,7 +13,6 @@ import { useInfiniteQuery, } from '@tanstack/react-query' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useAgent} from '#/state/session' import { diff --git a/src/view/com/post-thread/PostQuotes.tsx b/src/view/com/post-thread/PostQuotes.tsx index a22000b969..82619a8a51 100644 --- a/src/view/com/post-thread/PostQuotes.tsx +++ b/src/view/com/post-thread/PostQuotes.tsx @@ -2,13 +2,13 @@ import {useCallback, useState} from 'react' import { AppBskyFeedDefs, AppBskyFeedPost, + moderatePost, ModerationDecision, } from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {cleanError} from '#/lib/strings/errors' import {logger} from '#/logger' import {useModerationOpts} from '#/state/preferences/moderation-opts' diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 1bdee53075..ca77e34044 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -3,7 +3,11 @@ import {StyleSheet, useWindowDimensions, View} from 'react-native' import {runOnJS} from 'react-native-reanimated' import Animated from 'react-native-reanimated' import {useSafeAreaInsets} from 'react-native-safe-area-context' -import {AppBskyFeedDefs, AppBskyFeedThreadgate} from '@atproto/api' +import { + AppBskyFeedDefs, + AppBskyFeedThreadgate, + moderatePost, +} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -12,7 +16,6 @@ import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' import {useMinimalShellFabTransform} from '#/lib/hooks/useMinimalShellTransform' import {useSetTitle} from '#/lib/hooks/useSetTitle' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {clamp} from '#/lib/numbers' import {ScrollProvider} from '#/lib/ScrollContext' import {sanitizeDisplayName} from '#/lib/strings/display-names' diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index c87e361e16..6e57ea6877 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -4,6 +4,7 @@ import { AppBskyFeedDefs, AppBskyFeedPost, AtUri, + moderatePost, ModerationDecision, RichText as RichTextAPI, } from '@atproto/api' @@ -14,7 +15,6 @@ import {useQueryClient} from '@tanstack/react-query' import {MAX_POST_LINES} from '#/lib/constants' import {usePalette} from '#/lib/hooks/usePalette' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {makeProfileLink} from '#/lib/routes/links' import {countLines} from '#/lib/strings/helpers' import {colors, s} from '#/lib/styles' diff --git a/src/view/com/util/post-embeds/QuoteEmbed.tsx b/src/view/com/util/post-embeds/QuoteEmbed.tsx index cb549f7cda..9a9e27a023 100644 --- a/src/view/com/util/post-embeds/QuoteEmbed.tsx +++ b/src/view/com/util/post-embeds/QuoteEmbed.tsx @@ -14,6 +14,7 @@ import { AppBskyEmbedVideo, AppBskyFeedDefs, AppBskyFeedPost, + moderatePost, ModerationDecision, RichText as RichTextAPI, } from '@atproto/api' @@ -26,7 +27,6 @@ import {useQueryClient} from '@tanstack/react-query' import {HITSLOP_20} from '#/lib/constants' import {usePalette} from '#/lib/hooks/usePalette' import {InfoCircleIcon} from '#/lib/icons' -import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {makeProfileLink} from '#/lib/routes/links' import {s} from '#/lib/styles' import {useModerationOpts} from '#/state/preferences/moderation-opts' From 85e1987028d3710075c9f27b5327f4b8d7ef099f Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 20 Dec 2024 13:43:09 -0600 Subject: [PATCH 2/2] Bump SDK --- package.json | 2 +- yarn.lock | 54 ++++++++-------------------------------------------- 2 files changed, 9 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 574ca2639d..3b728e4182 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "icons:optimize": "svgo -f ./assets/icons" }, "dependencies": { - "@atproto/api": "^0.13.21", + "@atproto/api": "^0.13.22", "@braintree/sanitize-url": "^6.0.2", "@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet", "@emoji-mart/react": "^1.1.1", diff --git a/yarn.lock b/yarn.lock index bce716f6e7..fae2155099 100644 --- a/yarn.lock +++ b/yarn.lock @@ -72,10 +72,10 @@ tlds "^1.234.0" zod "^3.23.8" -"@atproto/api@^0.13.21": - version "0.13.21" - resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.21.tgz#8ee27a07e5a024b5bf32408d9bd623dd598ad1cc" - integrity sha512-iOxSj2YS3Fx9IPz1NivKrSsdYPNbBgpnUH7+WhKYAMvDFDUe2PZe7taau8wsUjJAu/H3S0Mk2TDh5e/7tCRwHA== +"@atproto/api@^0.13.22": + version "0.13.22" + resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.22.tgz#def614a2c08aecc025eab49ca1764df42ede389b" + integrity sha512-r8lYX/ur7ohSnItqEEAGR0A8KtbZJZyKXTihXuH4Sre4TTpWSAEbNmpPPzq8UwMAzgCMo/lVzZVj/nBHVUJ0/g== dependencies: "@atproto/common-web" "^0.3.1" "@atproto/lexicon" "^0.4.4" @@ -3261,7 +3261,7 @@ "@babel/parser" "^7.25.9" "@babel/types" "^7.25.9" -"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3": +"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.9.tgz#a50f8fe49e7f69f53de5bea7e413cd35c5e13c84" integrity sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw== @@ -3322,19 +3322,6 @@ debug "^4.3.1" globals "^11.1.0" -"@babel/traverse@^7.25.3", "@babel/traverse@^7.25.9": - version "7.25.9" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.9.tgz#a50f8fe49e7f69f53de5bea7e413cd35c5e13c84" - integrity sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw== - dependencies: - "@babel/code-frame" "^7.25.9" - "@babel/generator" "^7.25.9" - "@babel/parser" "^7.25.9" - "@babel/template" "^7.25.9" - "@babel/types" "^7.25.9" - debug "^4.3.1" - globals "^11.1.0" - "@babel/types@^7.0.0", "@babel/types@^7.20.0", "@babel/types@^7.20.7", "@babel/types@^7.22.10", "@babel/types@^7.22.5", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.22.10" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.22.10.tgz#4a9e76446048f2c66982d1a989dd12b8a2d2dc03" @@ -17504,16 +17491,7 @@ string-natural-compare@^3.0.1: resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4" integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw== -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -17613,7 +17591,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -17627,13 +17605,6 @@ strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -18908,7 +18879,7 @@ wordwrap@^1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -18926,15 +18897,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.0.1, wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"