Fixed kind1 posting mode
This commit is contained in:
parent
cbae1d1a95
commit
b470e0041d
@ -59,7 +59,7 @@ func (p *Poster) PostContent(
|
|||||||
caption string,
|
caption string,
|
||||||
hashtags []string,
|
hashtags []string,
|
||||||
) error {
|
) error {
|
||||||
// Default to kind20 if not found
|
// Get post mode from the database or default to kind20
|
||||||
postMode := "kind20"
|
postMode := "kind20"
|
||||||
|
|
||||||
// Logger post mode for easier debugging
|
// Logger post mode for easier debugging
|
||||||
@ -205,15 +205,48 @@ func (p *Poster) PostContent(
|
|||||||
hashtags,
|
hashtags,
|
||||||
)
|
)
|
||||||
} else if postMode == "kind1" {
|
} else if postMode == "kind1" {
|
||||||
// Use kind 1 (text note) with media attachment
|
// Use kind 1 (text note) with media attachment - enhanced for better compatibility
|
||||||
event, err = p.eventMgr.CreateAndSignMediaEvent(
|
// Create tags for better compatibility
|
||||||
|
var tags []nostr.Tag
|
||||||
|
|
||||||
|
// Add hashtags to tags
|
||||||
|
for _, tag := range hashtags {
|
||||||
|
tags = append(tags, nostr.Tag{"t", tag})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create imeta tag for metadata
|
||||||
|
imeta := []string{"imeta", "url " + mediaURL, "m " + contentType}
|
||||||
|
if mediaHash != "" {
|
||||||
|
imeta = append(imeta, "x "+mediaHash)
|
||||||
|
}
|
||||||
|
if altText != "" {
|
||||||
|
imeta = append(imeta, "alt "+altText)
|
||||||
|
}
|
||||||
|
tags = append(tags, imeta)
|
||||||
|
|
||||||
|
// Add multiple tag types for maximum client compatibility
|
||||||
|
tags = append(tags, nostr.Tag{"url", mediaURL})
|
||||||
|
tags = append(tags, nostr.Tag{"image", mediaURL})
|
||||||
|
tags = append(tags, nostr.Tag{"media", mediaURL})
|
||||||
|
tags = append(tags, nostr.Tag{"picture", mediaURL})
|
||||||
|
|
||||||
|
// Create content with URL directly embedded for better client compatibility
|
||||||
|
content := ""
|
||||||
|
if caption != "" {
|
||||||
|
content = caption + "\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the media URL directly in the content
|
||||||
|
content += mediaURL + "\n\n"
|
||||||
|
|
||||||
|
// Add hashtags at the end
|
||||||
|
content += hashtagStr
|
||||||
|
|
||||||
|
// Use CreateAndSignTextNoteEvent instead of MediaEvent for more control over tags
|
||||||
|
event, err = p.eventMgr.CreateAndSignTextNoteEvent(
|
||||||
pubkey,
|
pubkey,
|
||||||
caption,
|
content,
|
||||||
mediaURL,
|
tags,
|
||||||
contentType,
|
|
||||||
mediaHash,
|
|
||||||
altText,
|
|
||||||
hashtags,
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// Default: Use kind 20 (picture post) for better media compatibility
|
// Default: Use kind 20 (picture post) for better media compatibility
|
||||||
@ -316,7 +349,7 @@ func (p *Poster) PostContentWithEncoding(
|
|||||||
caption string,
|
caption string,
|
||||||
hashtags []string,
|
hashtags []string,
|
||||||
) (*models.EventResponse, error) {
|
) (*models.EventResponse, error) {
|
||||||
// Default to kind20 if not found
|
// Get post mode from the database or default to kind20
|
||||||
postMode := "kind20"
|
postMode := "kind20"
|
||||||
|
|
||||||
// Log post mode for easier debugging
|
// Log post mode for easier debugging
|
||||||
|
Loading…
x
Reference in New Issue
Block a user