Fixed kind1 posting mode
This commit is contained in:
parent
cbae1d1a95
commit
b470e0041d
@ -59,7 +59,7 @@ func (p *Poster) PostContent(
|
||||
caption string,
|
||||
hashtags []string,
|
||||
) error {
|
||||
// Default to kind20 if not found
|
||||
// Get post mode from the database or default to kind20
|
||||
postMode := "kind20"
|
||||
|
||||
// Logger post mode for easier debugging
|
||||
@ -205,15 +205,48 @@ func (p *Poster) PostContent(
|
||||
hashtags,
|
||||
)
|
||||
} else if postMode == "kind1" {
|
||||
// Use kind 1 (text note) with media attachment
|
||||
event, err = p.eventMgr.CreateAndSignMediaEvent(
|
||||
// Use kind 1 (text note) with media attachment - enhanced for better compatibility
|
||||
// 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,
|
||||
caption,
|
||||
mediaURL,
|
||||
contentType,
|
||||
mediaHash,
|
||||
altText,
|
||||
hashtags,
|
||||
content,
|
||||
tags,
|
||||
)
|
||||
} else {
|
||||
// Default: Use kind 20 (picture post) for better media compatibility
|
||||
@ -316,7 +349,7 @@ func (p *Poster) PostContentWithEncoding(
|
||||
caption string,
|
||||
hashtags []string,
|
||||
) (*models.EventResponse, error) {
|
||||
// Default to kind20 if not found
|
||||
// Get post mode from the database or default to kind20
|
||||
postMode := "kind20"
|
||||
|
||||
// Log post mode for easier debugging
|
||||
|
Loading…
x
Reference in New Issue
Block a user