This handles both normal & replys
(pds string, token string, my_did string, status string, in_reply_to *string, mentions []bridge.FacetParsing, urls []bridge.FacetParsing, tags []bridge.FacetParsing, imageBlob *Blob, imageRes []int)
| 1030 | |
| 1031 | // This handles both normal & replys |
| 1032 | func UpdateStatus(pds string, token string, my_did string, status string, in_reply_to *string, mentions []bridge.FacetParsing, urls []bridge.FacetParsing, tags []bridge.FacetParsing, imageBlob *Blob, imageRes []int) (*ThreadRoot, error) { |
| 1033 | url := pds + "/xrpc/com.atproto.repo.createRecord" |
| 1034 | |
| 1035 | var replySubject *ReplySubject |
| 1036 | var err error |
| 1037 | facets := []Facet{} |
| 1038 | embeds := Embed{} |
| 1039 | |
| 1040 | // find mention's DID |
| 1041 | handles := []string{} |
| 1042 | for _, mention := range mentions { |
| 1043 | handles = append(handles, mention.Item) |
| 1044 | } |
| 1045 | mentionedUsers, err := GetUsersInfo(pds, token, handles, false) |
| 1046 | |
| 1047 | // add mentions to the facets |
| 1048 | if err == nil { |
| 1049 | for _, mention := range mentions { |
| 1050 | var mentionDID *string |
| 1051 | for _, user := range mentionedUsers { |
| 1052 | if user.ScreenName == mention.Item { |
| 1053 | mentionDID, _ = bridge.TwitterIDToBlueSky(&user.ID) // efficency is poor |
| 1054 | break |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | if mentionDID == nil { |
| 1059 | continue |
| 1060 | } |
| 1061 | |
| 1062 | facets = append(facets, Facet{ |
| 1063 | Index: Index{ |
| 1064 | ByteStart: mention.Start, |
| 1065 | ByteEnd: mention.End, |
| 1066 | }, |
| 1067 | Features: []Feature{ |
| 1068 | { |
| 1069 | Type: "app.bsky.richtext.facet#mention", |
| 1070 | Did: *mentionDID, |
| 1071 | }, |
| 1072 | }, |
| 1073 | }) |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | // add URLs to the facets |
| 1078 | for _, url := range urls { |
| 1079 | facets = append(facets, Facet{ |
| 1080 | Index: Index{ |
| 1081 | ByteStart: url.Start, |
| 1082 | ByteEnd: url.End, |
| 1083 | }, |
| 1084 | Features: []Feature{ |
| 1085 | { |
| 1086 | Type: "app.bsky.richtext.facet#link", |
| 1087 | Uri: url.Item, |
| 1088 | }, |
| 1089 | }, |
nothing calls this directly
no test coverage detected