@@ -2,6 +2,7 @@ import * as Skins from "../data/skins";
22import {
33 AppBskyEmbedImages ,
44 AppBskyFeedPost ,
5+ AppBskyRichtextFacet ,
56 AtpAgent ,
67 BlobRef ,
78 RichText ,
@@ -58,8 +59,6 @@ async function post(md5: string): Promise<string> {
5859 const url = skin . getMuseumUrl ( ) ;
5960 const screenshotFileName = await skin . getScreenshotFileName ( ) ;
6061
61- const status = `${ name } \n` ; // TODO: Should we add hashtags?
62-
6362 await agent . login ( {
6463 identifier : BLUESKY_USERNAME ! ,
6564 password : BLUESKY_PASSWORD ! ,
@@ -73,48 +72,34 @@ async function post(md5: string): Promise<string> {
7372 }
7473 ) ;
7574
75+ const facets : AppBskyRichtextFacet . Main [ ] = [
76+ {
77+ $type : "app.bsky.richtext.facet" ,
78+ index : {
79+ byteStart : 0 ,
80+ byteEnd : name . length ,
81+ } ,
82+ features : [
83+ {
84+ $type : "app.bsky.richtext.facet#link" ,
85+ uri : url ,
86+ } ,
87+ ] ,
88+ } ,
89+ ] ;
90+
7691 const postData = await buildPost (
77- agent ,
78- status ,
92+ ` ${ name } via the Winamp Skin Museum` ,
93+ facets ,
7994 buildImageEmbed ( blob , width * 2 , height * 2 )
8095 ) ;
8196 const postResp = await agent . post ( postData ) ;
82- console . log ( postResp ) ;
8397
8498 const postId = postResp . cid ;
8599 const postUrl = postResp . uri ;
86100
87101 await Skins . markAsPostedToBlueSky ( md5 , postId , postUrl ) ;
88102
89- const prefix = "Try on the " ;
90- const suffix = "Winamp Skin Museum" ;
91-
92- agent . post ( {
93- text : prefix + suffix ,
94- createdAt : new Date ( ) . toISOString ( ) ,
95- facets : [
96- {
97- $type : "app.bsky.richtext.facet" ,
98- index : {
99- byteStart : prefix . length ,
100- byteEnd : prefix . length + suffix . length ,
101- } ,
102- features : [
103- {
104- $type : "app.bsky.richtext.facet#link" ,
105- uri : url ,
106- } ,
107- ] ,
108- } ,
109- ] ,
110- reply : {
111- root : postResp ,
112- parent : postResp ,
113- } ,
114- $type : "app.bsky.feed.post" ,
115- } ) ;
116-
117- // return permalink;
118103 return postUrl ;
119104}
120105
@@ -137,13 +122,10 @@ function buildImageEmbed(
137122
138123/** Build the post data for an image. */
139124async function buildPost (
140- agent : AtpAgent ,
141- rawText : string ,
125+ text : string ,
126+ facets : AppBskyRichtextFacet . Main [ ] ,
142127 imageEmbed : AppBskyEmbedImages . Main
143128) : Promise < AppBskyFeedPost . Record > {
144- const rt = new RichText ( { text : rawText } ) ;
145- await rt . detectFacets ( agent ) ;
146- const { text, facets } = rt ;
147129 return {
148130 text,
149131 facets,
0 commit comments