diff --git a/newsletter.go b/newsletter.go index 75e81ee9..7de2ec1c 100644 --- a/newsletter.go +++ b/newsletter.go @@ -159,11 +159,11 @@ type respGetNewsletterInfo struct { Newsletter *types.NewsletterMetadata `json:"xwa2_newsletter"` } -func (cli *Client) getNewsletterInfo(input map[string]any) (*types.NewsletterMetadata, error) { +func (cli *Client) getNewsletterInfo(input map[string]any, fetchViewerMeta bool) (*types.NewsletterMetadata, error) { data, err := cli.sendMexIQ(context.TODO(), queryFetchNewsletter, map[string]any{ "fetch_creation_time": true, "fetch_full_image": true, - "fetch_viewer_metadata": true, + "fetch_viewer_metadata": fetchViewerMeta, "input": input, }) if err != nil { @@ -182,17 +182,19 @@ func (cli *Client) GetNewsletterInfo(jid types.JID) (*types.NewsletterMetadata, return cli.getNewsletterInfo(map[string]any{ "key": jid.String(), "type": types.NewsletterKeyTypeJID, - }) + }, true) } // GetNewsletterInfoWithInvite gets the info of a newsletter with an invite link. // // You can either pass the full link (https://whatsapp.com/channel/...) or just the `...` part. +// +// Note that the ViewerMeta field of the returned NewsletterMetadata will be nil. func (cli *Client) GetNewsletterInfoWithInvite(key string) (*types.NewsletterMetadata, error) { return cli.getNewsletterInfo(map[string]any{ "key": strings.TrimPrefix(key, NewsletterLinkPrefix), "type": types.NewsletterKeyTypeInvite, - }) + }, false) } type CreateNewsletterParams struct { diff --git a/types/newsletter.go b/types/newsletter.go index 27846542..511216c4 100644 --- a/types/newsletter.go +++ b/types/newsletter.go @@ -97,10 +97,10 @@ const ( ) type NewsletterMetadata struct { - ID JID `json:"id"` - State WrappedNewsletterState `json:"state"` - ThreadMeta NewsletterThreadMetadata `json:"thread_metadata"` - ViewerMeta NewsletterViewerMetadata `json:"viewer_metadata"` + ID JID `json:"id"` + State WrappedNewsletterState `json:"state"` + ThreadMeta NewsletterThreadMetadata `json:"thread_metadata"` + ViewerMeta *NewsletterViewerMetadata `json:"viewer_metadata"` } type NewsletterViewerMetadata struct {