Skip to content

Commit

Permalink
Update doc comments; remove unneeded property
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuatbrown committed Sep 16, 2024
1 parent d9cf503 commit a44cf5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions Nos/Models/OpenGraph/OpenGraphParser.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation

/// Parses the Open Graph metadata from an HTML document.
protocol OpenGraphParser {
func videoMetadata(html: Data) -> OpenGraphMedia?
}
Expand Down
2 changes: 1 addition & 1 deletion Nos/Service/Media/MediaService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct DefaultMediaService: MediaService {
}
}

/// Loads the content at the given URL and returns its orientation.
/// Fetches metadata for the given URL and returns its orientation.
/// - Parameter url: The URL of the data to download.
/// - Returns: The orientation of the content.
/// - Note: For web pages, `landscape` is returned. For videos, we're returning `portrait` until we implement
Expand Down
9 changes: 8 additions & 1 deletion Nos/Service/Media/OpenGraphService.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import Foundation

/// A service that fetches metadata for a URL.
protocol OpenGraphService {
/// Fetches metadata for the given URL.
/// - Parameter url: The URL to fetch.
/// - Returns: The Open Graph metadata for the URL.
func fetchMetadata(for url: URL) async throws -> OpenGraphMetadata
}

/// A default implementation for `OpenGraphService`.
struct DefaultOpenGraphService: OpenGraphService {
let session: URLSessionProtocol
let parser: OpenGraphParser
Expand All @@ -16,17 +21,19 @@ struct DefaultOpenGraphService: OpenGraphService {
}
}

/// Open Graph metadata for a URL.
struct OpenGraphMetadata: Equatable {
let media: OpenGraphMedia?
}

/// Open Graph metadata for media, such as an image or video.
struct OpenGraphMedia: Equatable {
let url: String?
let type: OpenGraphMediaType?
let width: Double?
let height: Double?
}

/// The type of Open Graph media.
enum OpenGraphMediaType {
case image
case video
Expand Down

0 comments on commit a44cf5f

Please sign in to comment.