mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Added Reddit extension point enablement
This commit is contained in:
@@ -24,9 +24,8 @@ public enum RedditFeedProviderError: LocalizedError {
|
||||
|
||||
public struct RedditFeedProvider: FeedProvider {
|
||||
|
||||
private static let server = "api.twitter.com"
|
||||
private static let apiBase = "https://api.twitter.com/1.1/"
|
||||
private static let dateFormat = "EEE MMM dd HH:mm:ss Z yyyy"
|
||||
private static let server = "www.reddit.com"
|
||||
private static let apiBase = "https://oauth.reddit.com"
|
||||
|
||||
private static let userPaths = ["/home", "/notifications"]
|
||||
private static let reservedPaths = ["/search", "/explore", "/messages", "/i", "/compose"]
|
||||
@@ -150,6 +149,24 @@ extension RedditFeedProvider: OAuth2SwiftProvider {
|
||||
return oauth2
|
||||
}
|
||||
|
||||
public static var callbackURL: URL {
|
||||
return URL(string: "netnewswire://success")!
|
||||
}
|
||||
|
||||
public static var oauth2Vars: (state: String, scope: String, params: [String : String]) {
|
||||
let state = generateState(withLength: 20)
|
||||
let scope = "identity mysubreddits"
|
||||
let params = [
|
||||
"client_id" : Secrets.redditConsumerKey,
|
||||
"response_type" : "code",
|
||||
"state" : state,
|
||||
"redirect_uri" : "netnewswire://success",
|
||||
"duration" : "permanent",
|
||||
"scope" : scope
|
||||
]
|
||||
return (state: state, scope: scope, params: params)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension RedditFeedProvider {
|
||||
|
||||
@@ -263,6 +263,10 @@ public struct TwitterFeedProvider: FeedProvider {
|
||||
|
||||
extension TwitterFeedProvider: OAuth1SwiftProvider {
|
||||
|
||||
public static var callbackURL: URL {
|
||||
return URL(string: "netnewswire://")!
|
||||
}
|
||||
|
||||
public static var oauth1Swift: OAuth1Swift {
|
||||
return OAuth1Swift(
|
||||
consumerKey: Secrets.twitterConsumerKey,
|
||||
|
||||
@@ -12,5 +12,6 @@ import OAuthSwift
|
||||
public protocol OAuth1SwiftProvider {
|
||||
|
||||
static var oauth1Swift: OAuth1Swift { get }
|
||||
static var callbackURL: URL { get }
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ import OAuthSwift
|
||||
public protocol OAuth2SwiftProvider {
|
||||
|
||||
static var oauth2Swift: OAuth2Swift { get }
|
||||
static var callbackURL: URL { get }
|
||||
static var oauth2Vars: (state: String, scope: String, params: [String: String]) { get }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user