Skip to content

Commit

Permalink
Add ref code for appdb links
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecNew10 committed Apr 6, 2023
1 parent 0dc7772 commit 437c356
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions appdb/Startup/Global.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ enum Global {
static let adsTestMode: Bool = !DEBUG

static let mainSite: String = "https://appdb.to/"
static let refCode: String = "fc2b87d32abe29180b9da168d5a599e8"

static let githubSite: String = "https://github.com/n3d1117/appdb"
static let donateSite: String = "https://www.buymeacoffee.com/ne_do"
// static let email: String = "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Featured/Details/Details.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Details: LoadingTableView {
// MARK: - Share

@objc func share(sender: UIBarButtonItem) {
let urlString = "\(Global.mainSite)app/\(contentType.rawValue)/\(content.itemId)"
let urlString = "\(Global.mainSite)app/\(contentType.rawValue)/\(content.itemId)?ref=\(Global.refCode)"
guard let url = URL(string: urlString) else { return }
let activity = UIActivityViewController(activityItems: [url], applicationActivities: [SafariActivity()])
if #available(iOS 11.0, *) {} else {
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Settings/Credits/Credits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Credits: TableViewController {
Credit(name: "View project on GitHub".localized(), imageName: "github", type: .developer, handle: .website(site: Global.githubSite)),
Credit(name: "Buy me a coffee".localized(), imageName: "bmac", type: .developer, handle: .website(site: Global.donateSite)),

Credit(name: "appdb team", imageName: "appdb", type: .specialThanks, handle: .website(site: Global.mainSite)),
Credit(name: "appdb team", imageName: "appdb", type: .specialThanks, handle: .website(site: Global.mainSite + "?ref=" + Global.refCode)),
Credit(name: "Alessandro Chiarlitti (aesign)", detail: "Icon and banner designer".localized(), imageName: "aesign", type: .specialThanks, handle: .website(site: "https://aesign.me")),

Credit(name: "TNT 🇪🇸", imageName: "tnt", type: .translations, handle: .none),
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Settings/Device Link/BulletinDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum DeviceLinkIntroBulletins {
if page.deviceIsNotYetLinked {
// If device is not yet linked to appdb there's not much I can do: just redirect
// user to the web page where he can link it (APIs to link manually no longer work)
let linkPageUrlString = "\(Global.mainSite)link"
let linkPageUrlString = "\(Global.mainSite)link?ref=\(Global.refCode)"
NotificationCenter.default.post(name: .OpenSafari, object: self, userInfo: ["URLString": "\(linkPageUrlString)"])
} else {
item.manager?.displayActivityIndicator(color: Themes.isNight ? .white : .black)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class EnterLinkCodeBulletinPage: BLTNPageItem {

@objc private func linkButtonTapped(sender: UIButton) {
guard let url = sender.titleLabel?.text else { return }
NotificationCenter.default.post(name: .OpenSafari, object: self, userInfo: ["URLString": "\(url)"])
NotificationCenter.default.post(name: .OpenSafari, object: self, userInfo: ["URLString": "\(url)?ref=\(Global.refCode)"])
}

override func actionButtonTapped(sender: UIButton) {
Expand Down
6 changes: 3 additions & 3 deletions appdb/Tabs/Settings/News/News+Detail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class NewsDetail: LoadingTableView {

@objc private func share(sender: UIBarButtonItem) {
let text = item.title
let urlString = "\(Global.mainSite)news/\(item.id)"
let urlString = "\(Global.mainSite)news/\(item.id)?ref=\(Global.refCode)"
guard let url = URL(string: urlString) else { return }
let activity = UIActivityViewController(activityItems: [text, url], applicationActivities: [SafariActivity()])
if #available(iOS 11.0, *) {} else {
Expand Down Expand Up @@ -199,7 +199,7 @@ extension AttributedLabel {
switch detection.type {
case .link(let url):
var partialUrl = url.absoluteString.replacingOccurrences(of: "&", with: "&")
if !partialUrl.hasPrefix("http") { partialUrl = "http://" + partialUrl }
if !partialUrl.hasPrefix("http") { partialUrl = "http://" + partialUrl + "&ref=\(Global.refCode)" }
guard let fullUrl = URL(string: partialUrl) else { return }
UIApplication.shared.open(fullUrl)
case .tag(let tag):
Expand All @@ -209,7 +209,7 @@ extension AttributedLabel {
UIApplication.shared.open(url)
} else {
while href.hasPrefix("/") { href = String(href.dropFirst()) }
let urlString: String = "\(Global.mainSite)\(href)".replacingOccurrences(of: "&", with: "&")
let urlString: String = "\(Global.mainSite)\(href)&ref=\(Global.refCode)".replacingOccurrences(of: "&", with: "&")
guard let url = URL(string: urlString) else { return }
UIApplication.shared.open(url)
}
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Settings/Settings+Sections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension Settings {
}

var proSite: String {
Global.mainSite + "my/buy?lt=" + Preferences.linkToken
Global.mainSite + "my/buy?ref=" + Global.refCode + "&lt=" + Preferences.linkToken
}

var themeSection: [Static.Section] {
Expand Down

0 comments on commit 437c356

Please sign in to comment.