Class OpenGraphEmbeddedCardGenerator
- Namespace
- idunno.Bluesky.Embed
- Assembly
- idunno.Bluesky.dll
Creates an OpenCard embed, which is a card that can be embedded in Bluesky posts, displaying richer content from a URL. This is used for embedding external content such as websites, videos, and other media.
public class OpenGraphEmbeddedCardGenerator : BaseEmbeddedCardGenerator, IEmbeddedCardGenerator, IDisposableInheritance
Derived
Implements
Inherited Members
Constructors
OpenGraphEmbeddedCardGenerator(BlueskyAgent)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, ILoggerFactory?)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, ILoggerFactory? loggerFactory)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
loggerFactoryILoggerFactory?-
The Microsoft.Extensions.Logging.ILoggerFactory to use for logging. If null, a no-op logger will be used.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, ILogger)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
protected OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, ILogger logger)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
loggerILogger-
The Microsoft.Extensions.Logging.ILogger to use for logging.
Exceptions
- ArgumentNullException
-
Thrown if
agentorloggeris null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, HttpClient, ILoggerFactory?)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, HttpClient httpClient, ILoggerFactory? loggerFactory)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
httpClientHttpClient-
The System.Net.Http.HttpClient to use for making HTTP requests to retrieve OpenGraph data. Ensure the client is hardened against SSRF attacks.
loggerFactoryILoggerFactory?-
The Microsoft.Extensions.Logging.ILoggerFactory to use for logging. If null, a no-op logger will be used.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, HttpClient, ILogger)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
protected OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, HttpClient httpClient, ILogger logger)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
httpClientHttpClient-
The System.Net.Http.HttpClient to use for making HTTP requests to retrieve OpenGraph data. Ensure the client is hardened against SSRF attacks.
loggerILogger-
The Microsoft.Extensions.Logging.ILogger to use for logging.
Exceptions
- ArgumentNullException
-
Thrown if
agent,httpClient, orloggeris null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, ILoggerFactory?)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, ILoggerFactory? loggerFactory)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
loggerFactoryILoggerFactory?-
The Microsoft.Extensions.Logging.ILoggerFactory to use for logging. If null, a no-op logger will be used.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, ILogger)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
protected OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, ILogger logger)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
loggerILogger-
The Microsoft.Extensions.Logging.ILogger to use for logging.
Exceptions
- ArgumentNullException
-
Thrown if
agentorloggeris null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, HttpClient, ILoggerFactory?)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, HttpClient httpClient, ILoggerFactory? loggerFactory)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
httpClientHttpClient-
The System.Net.Http.HttpClient to use for making HTTP requests to retrieve OpenGraph data. Ensure the client is hardened against SSRF attacks.
loggerFactoryILoggerFactory?-
The Microsoft.Extensions.Logging.ILoggerFactory to use for logging. If null, a no-op logger will be used.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, HttpClient, ILogger)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
protected OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, HttpClient httpClient, ILogger logger)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
httpClientHttpClient-
The System.Net.Http.HttpClient to use for making HTTP requests to retrieve OpenGraph data. Ensure the client is hardened against SSRF attacks.
loggerILogger-
The Microsoft.Extensions.Logging.ILogger to use for logging.
Exceptions
- ArgumentNullException
-
Thrown if
agent,httpClient, orloggeris null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, ILoggerFactory?)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, ILoggerFactory? loggerFactory)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
loggerFactoryILoggerFactory?-
The Microsoft.Extensions.Logging.ILoggerFactory to use for logging. If null, a no-op logger will be used.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, ILogger)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
protected OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, ILogger logger)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
loggerILogger-
The Microsoft.Extensions.Logging.ILogger to use for logging.
Exceptions
- ArgumentNullException
-
Thrown if
agentorloggeris null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, HttpClient, ILoggerFactory?)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
public OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, HttpClient httpClient, ILoggerFactory? loggerFactory)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
httpClientHttpClient-
The System.Net.Http.HttpClient to use for making HTTP requests to retrieve OpenGraph data. Ensure the client is hardened against SSRF attacks.
loggerFactoryILoggerFactory?-
The Microsoft.Extensions.Logging.ILoggerFactory to use for logging. If null, a no-op logger will be used.
Exceptions
- ArgumentNullException
-
Thrown if
agentis null.
OpenGraphEmbeddedCardGenerator(BlueskyAgent, HttpClient, ILogger)
Creates a new instance of idunno.Bluesky.Embed.OpenGraphEmbeddedCardGenerator.
protected OpenGraphEmbeddedCardGenerator(BlueskyAgent agent, HttpClient httpClient, ILogger logger)Parameters
agentBlueskyAgent-
The idunno.Bluesky.BlueskyAgent to use for thumbnail uploading.
httpClientHttpClient-
The System.Net.Http.HttpClient to use for making HTTP requests to retrieve OpenGraph data. Ensure the client is hardened against SSRF attacks.
loggerILogger-
The Microsoft.Extensions.Logging.ILogger to use for logging.
Exceptions
- ArgumentNullException
-
Thrown if
agent,httpClient, orloggeris null.
Methods
CreateEmbeddedExternalFromOpenGraphMetadata(Uri, string, CancellationToken)
Creates an idunno.Bluesky.Embed.EmbeddedExternal from OpenGraph metadata.
protected Task<EmbeddedExternal?> CreateEmbeddedExternalFromOpenGraphMetadata(Uri uri, string pageContent, CancellationToken cancellationToken = default)Parameters
uriUri-
The URI to retrieve OpenGraph data from.
pageContentstring-
The HTML content of the page.
cancellationTokenCancellationToken-
A token to cancel the operation.
Returns
- Task<EmbeddedExternal?>
-
An idunno.Bluesky.Embed.EmbeddedExternal if enough OpenGraph data is found; otherwise, null.
Exceptions
- ArgumentNullException
-
Thrown if
uriis null - ArgumentException
-
Thrown if
uriis not an absolute URI.
CreateEmbeddedExternalFromOpenGraphMetadata(Uri, string, CancellationToken)
Creates an idunno.Bluesky.Embed.EmbeddedExternal from OpenGraph metadata.
protected Task<EmbeddedExternal?> CreateEmbeddedExternalFromOpenGraphMetadata(Uri uri, string pageContent, CancellationToken cancellationToken = default)Parameters
uriUri-
The URI to retrieve OpenGraph data from.
pageContentstring-
The HTML content of the page.
cancellationTokenCancellationToken-
A token to cancel the operation.
Returns
- Task<EmbeddedExternal?>
-
An idunno.Bluesky.Embed.EmbeddedExternal if enough OpenGraph data is found; otherwise, null.
Exceptions
- ArgumentNullException
-
Thrown if
uriis null - ArgumentException
-
Thrown if
uriis not an absolute URI.
CreateEmbeddedExternalFromOpenGraphMetadata(Uri, string, CancellationToken)
Creates an idunno.Bluesky.Embed.EmbeddedExternal from OpenGraph metadata.
protected Task<EmbeddedExternal?> CreateEmbeddedExternalFromOpenGraphMetadata(Uri uri, string pageContent, CancellationToken cancellationToken = default)Parameters
uriUri-
The URI to retrieve OpenGraph data from.
pageContentstring-
The HTML content of the page.
cancellationTokenCancellationToken-
A token to cancel the operation.
Returns
- Task<EmbeddedExternal?>
-
An idunno.Bluesky.Embed.EmbeddedExternal if enough OpenGraph data is found; otherwise, null.
Exceptions
- ArgumentNullException
-
Thrown if
uriis null - ArgumentException
-
Thrown if
uriis not an absolute URI.
Generate(Uri, CancellationToken)
Gets an idunno.Bluesky.Embed.EmbeddedExternal for uri, preferring OpenGraph data if available.
public override Task<EmbeddedExternal?> Generate(Uri uri, CancellationToken cancellationToken = default)Parameters
uriUri-
The URI to retrieve OpenGraph data from.
cancellationTokenCancellationToken-
A token to cancel the operation.
Returns
- Task<EmbeddedExternal?>
-
An idunno.Bluesky.Embed.EmbeddedExternal if the page can be fetched and a valid canonical URL can be determined; otherwise, null.
Exceptions
- ArgumentNullException
-
Thrown if
uriis null - ArgumentException
-
Thrown if
uriis not an absolute URI.
Generate(Uri, CancellationToken)
Gets an idunno.Bluesky.Embed.EmbeddedExternal for uri, preferring OpenGraph data if available.
public override Task<EmbeddedExternal?> Generate(Uri uri, CancellationToken cancellationToken = default)Parameters
uriUri-
The URI to retrieve OpenGraph data from.
cancellationTokenCancellationToken-
A token to cancel the operation.
Returns
- Task<EmbeddedExternal?>
-
An idunno.Bluesky.Embed.EmbeddedExternal if the page can be fetched and a valid canonical URL can be determined; otherwise, null.
Exceptions
- ArgumentNullException
-
Thrown if
uriis null - ArgumentException
-
Thrown if
uriis not an absolute URI.
Generate(Uri, CancellationToken)
Gets an idunno.Bluesky.Embed.EmbeddedExternal for uri, preferring OpenGraph data if available.
public override Task<EmbeddedExternal?> Generate(Uri uri, CancellationToken cancellationToken = default)Parameters
uriUri-
The URI to retrieve OpenGraph data from.
cancellationTokenCancellationToken-
A token to cancel the operation.
Returns
- Task<EmbeddedExternal?>
-
An idunno.Bluesky.Embed.EmbeddedExternal if the page can be fetched and a valid canonical URL can be determined; otherwise, null.
Exceptions
- ArgumentNullException
-
Thrown if
uriis null - ArgumentException
-
Thrown if
uriis not an absolute URI.