Get rid of commonglog
This commit is contained in:
parent
a46a0ca015
commit
74c324f9cf
|
@ -19,15 +19,6 @@
|
||||||
"version": "4.2.0"
|
"version": "4.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"package": "CommonOSLog",
|
|
||||||
"repositoryURL": "https://github.com/MainasuK/CommonOSLog",
|
|
||||||
"state": {
|
|
||||||
"branch": null,
|
|
||||||
"revision": "c121624a30698e9886efe38aebb36ff51c01b6c2",
|
|
||||||
"version": "0.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"package": "FaviconFinder",
|
"package": "FaviconFinder",
|
||||||
"repositoryURL": "https://github.com/will-lumley/FaviconFinder.git",
|
"repositoryURL": "https://github.com/will-lumley/FaviconFinder.git",
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
final class SearchHistoryViewModel {
|
final class SearchHistoryViewModel {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import GameplayKit
|
import GameplayKit
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ let package = Package(
|
||||||
.package(url: "https://github.com/kean/Nuke-FLAnimatedImage-Plugin.git", from: "8.0.0"),
|
.package(url: "https://github.com/kean/Nuke-FLAnimatedImage-Plugin.git", from: "8.0.0"),
|
||||||
.package(url: "https://github.com/kean/Nuke.git", from: "10.3.1"),
|
.package(url: "https://github.com/kean/Nuke.git", from: "10.3.1"),
|
||||||
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", from: "4.2.2"),
|
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", from: "4.2.2"),
|
||||||
.package(url: "https://github.com/MainasuK/CommonOSLog", from: "0.1.1"),
|
|
||||||
.package(url: "https://github.com/MainasuK/FPSIndicator.git", from: "1.0.0"),
|
.package(url: "https://github.com/MainasuK/FPSIndicator.git", from: "1.0.0"),
|
||||||
.package(url: "https://github.com/slackhq/PanModal.git", from: "1.2.7"),
|
.package(url: "https://github.com/slackhq/PanModal.git", from: "1.2.7"),
|
||||||
.package(url: "https://github.com/TimOliver/TOCropViewController.git", from: "2.6.1"),
|
.package(url: "https://github.com/TimOliver/TOCropViewController.git", from: "2.6.1"),
|
||||||
|
@ -93,7 +92,6 @@ let package = Package(
|
||||||
"MastodonSDK",
|
"MastodonSDK",
|
||||||
.product(name: "Alamofire", package: "Alamofire"),
|
.product(name: "Alamofire", package: "Alamofire"),
|
||||||
.product(name: "AlamofireImage", package: "AlamofireImage"),
|
.product(name: "AlamofireImage", package: "AlamofireImage"),
|
||||||
.product(name: "CommonOSLog", package: "CommonOSLog"),
|
|
||||||
.product(name: "ArkanaKeys", package: "ArkanaKeys"),
|
.product(name: "ArkanaKeys", package: "ArkanaKeys"),
|
||||||
.product(name: "KeychainAccess", package: "KeychainAccess"),
|
.product(name: "KeychainAccess", package: "KeychainAccess"),
|
||||||
.product(name: "MetaTextKit", package: "MetaTextKit")
|
.product(name: "MetaTextKit", package: "MetaTextKit")
|
||||||
|
|
|
@ -9,7 +9,6 @@ import os.log
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import Foundation
|
import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CommonOSLog
|
|
||||||
import MastodonCommon
|
import MastodonCommon
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
|
@ -49,8 +48,6 @@ extension APIService {
|
||||||
)
|
)
|
||||||
|
|
||||||
let flag = result.isNewInsertion ? "+" : "-"
|
let flag = result.isNewInsertion ? "+" : "-"
|
||||||
let logger = Logger(subsystem: "APIService", category: "AccountInfo")
|
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch mastodon user [\(flag)](\(response.value.id))\(response.value.username)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
@ -65,7 +64,6 @@ extension APIService {
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Relationship> {
|
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Relationship> {
|
||||||
let logger = Logger(subsystem: "APIService", category: "Block")
|
|
||||||
|
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
let blockContext: MastodonBlockContext = try await managedObjectContext.performChanges {
|
let blockContext: MastodonBlockContext = try await managedObjectContext.performChanges {
|
||||||
|
@ -84,7 +82,7 @@ extension APIService {
|
||||||
// will do block action. set to unfollow
|
// will do block action. set to unfollow
|
||||||
user.update(isFollowing: false, by: me)
|
user.update(isFollowing: false, by: me)
|
||||||
}
|
}
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user[\(user.id)](\(user.username)) block state: \(!isBlocking)")
|
|
||||||
return MastodonBlockContext(
|
return MastodonBlockContext(
|
||||||
sourceUserID: me.id,
|
sourceUserID: me.id,
|
||||||
targetUserID: user.id,
|
targetUserID: user.id,
|
||||||
|
@ -115,7 +113,6 @@ extension APIService {
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
result = .failure(error)
|
result = .failure(error)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(blockContext.targetUserID)](\(blockContext.targetUsername)) block failure: \(error.localizedDescription)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try await managedObjectContext.performChanges {
|
try await managedObjectContext.performChanges {
|
||||||
|
@ -135,12 +132,10 @@ extension APIService {
|
||||||
networkDate: response.networkDate
|
networkDate: response.networkDate
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(blockContext.targetUserID)](\(blockContext.targetUsername)) block state: \(relationship.blocking)")
|
|
||||||
case .failure:
|
case .failure:
|
||||||
// rollback
|
// rollback
|
||||||
user.update(isBlocking: blockContext.isBlocking, by: me)
|
user.update(isBlocking: blockContext.isBlocking, by: me)
|
||||||
user.update(isFollowing: blockContext.isFollowing, by: me)
|
user.update(isFollowing: blockContext.isFollowing, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] rollback user[\(blockContext.targetUserID)](\(blockContext.targetUsername)) block state")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import Combine
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ extension APIService {
|
||||||
record: ManagedObjectRecord<Status>,
|
record: ManagedObjectRecord<Status>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
|
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
|
||||||
let logger = Logger(subsystem: "APIService", category: "Bookmark")
|
|
||||||
|
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
|
|
||||||
|
@ -42,7 +40,6 @@ extension APIService {
|
||||||
statusID: status.id,
|
statusID: status.id,
|
||||||
isBookmarked: isBookmarked
|
isBookmarked: isBookmarked
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status bookmark: \(!isBookmarked)")
|
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +56,6 @@ extension APIService {
|
||||||
result = .success(response)
|
result = .success(response)
|
||||||
} catch {
|
} catch {
|
||||||
result = .failure(error)
|
result = .failure(error)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update bookmark failure: \(error.localizedDescription)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update bookmark state
|
// update bookmark state
|
||||||
|
@ -83,11 +79,9 @@ extension APIService {
|
||||||
networkDate: response.networkDate
|
networkDate: response.networkDate
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status bookmark: \(response.value.bookmarked.debugDescription)")
|
|
||||||
case .failure:
|
case .failure:
|
||||||
// rollback
|
// rollback
|
||||||
status.update(bookmarked: bookmarkContext.isBookmarked, by: me)
|
status.update(bookmarked: bookmarkContext.isBookmarked, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): rollback status bookmark")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
import CommonOSLog
|
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
|
@ -11,7 +11,6 @@ import Combine
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ extension APIService {
|
||||||
record: ManagedObjectRecord<Status>,
|
record: ManagedObjectRecord<Status>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
|
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
|
||||||
let logger = Logger(subsystem: "APIService", category: "Favorite")
|
|
||||||
|
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
|
|
||||||
|
@ -48,7 +46,6 @@ extension APIService {
|
||||||
isFavorited: isFavorited,
|
isFavorited: isFavorited,
|
||||||
favoritedCount: favoritedCount
|
favoritedCount: favoritedCount
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status favorite: \(!isFavorited), \(favoriteCount)")
|
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +62,6 @@ extension APIService {
|
||||||
result = .success(response)
|
result = .success(response)
|
||||||
} catch {
|
} catch {
|
||||||
result = .failure(error)
|
result = .failure(error)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update favorite failure: \(error.localizedDescription)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update like state
|
// update like state
|
||||||
|
@ -92,12 +88,10 @@ extension APIService {
|
||||||
if favoriteContext.isFavorited {
|
if favoriteContext.isFavorited {
|
||||||
status.update(favouritesCount: max(0, status.favouritesCount - 1)) // undo API return count has delay. Needs -1 local
|
status.update(favouritesCount: max(0, status.favouritesCount - 1)) // undo API return count has delay. Needs -1 local
|
||||||
}
|
}
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status favorite: \(response.value.favourited.debugDescription)")
|
|
||||||
case .failure:
|
case .failure:
|
||||||
// rollback
|
// rollback
|
||||||
status.update(liked: favoriteContext.isFavorited, by: me)
|
status.update(liked: favoriteContext.isFavorited, by: me)
|
||||||
status.update(favouritesCount: favoriteContext.favoritedCount)
|
status.update(favouritesCount: favoriteContext.favoritedCount)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): rollback status favorite")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
@ -34,7 +33,6 @@ extension APIService {
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Relationship> {
|
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Relationship> {
|
||||||
let logger = Logger(subsystem: "APIService", category: "Follow")
|
|
||||||
|
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
let _followContext: MastodonFollowContext? = try await managedObjectContext.performChanges {
|
let _followContext: MastodonFollowContext? = try await managedObjectContext.performChanges {
|
||||||
|
@ -49,17 +47,14 @@ extension APIService {
|
||||||
// unfollow
|
// unfollow
|
||||||
user.update(isFollowing: false, by: me)
|
user.update(isFollowing: false, by: me)
|
||||||
user.update(isFollowRequested: false, by: me)
|
user.update(isFollowRequested: false, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user friendship: undo follow")
|
|
||||||
} else {
|
} else {
|
||||||
// follow
|
// follow
|
||||||
if user.locked {
|
if user.locked {
|
||||||
user.update(isFollowing: false, by: me)
|
user.update(isFollowing: false, by: me)
|
||||||
user.update(isFollowRequested: true, by: me)
|
user.update(isFollowRequested: true, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user friendship: pending follow")
|
|
||||||
} else {
|
} else {
|
||||||
user.update(isFollowing: true, by: me)
|
user.update(isFollowing: true, by: me)
|
||||||
user.update(isFollowRequested: false, by: me)
|
user.update(isFollowRequested: false, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user friendship: following")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let context = MastodonFollowContext(
|
let context = MastodonFollowContext(
|
||||||
|
@ -88,7 +83,6 @@ extension APIService {
|
||||||
).singleOutput()
|
).singleOutput()
|
||||||
result = .success(response)
|
result = .success(response)
|
||||||
} catch {
|
} catch {
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update friendship failure: \(error.localizedDescription)")
|
|
||||||
result = .failure(error)
|
result = .failure(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +103,10 @@ extension APIService {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
let following = response.value.following
|
let following = response.value.following
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user friendship: following \(following)")
|
|
||||||
case .failure:
|
case .failure:
|
||||||
// rollback
|
// rollback
|
||||||
user.update(isFollowing: followContext.isFollowing, by: me)
|
user.update(isFollowing: followContext.isFollowing, by: me)
|
||||||
user.update(isFollowRequested: followContext.isPending, by: me)
|
user.update(isFollowRequested: followContext.isPending, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] rollback user friendship")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
@ -64,7 +63,6 @@ extension APIService {
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Relationship> {
|
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Relationship> {
|
||||||
let logger = Logger(subsystem: "APIService", category: "Mute")
|
|
||||||
|
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
let muteContext: MastodonMuteContext = try await managedObjectContext.performChanges {
|
let muteContext: MastodonMuteContext = try await managedObjectContext.performChanges {
|
||||||
|
@ -79,7 +77,6 @@ extension APIService {
|
||||||
|
|
||||||
// toggle mute state
|
// toggle mute state
|
||||||
user.update(isMuting: !isMuting, by: me)
|
user.update(isMuting: !isMuting, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Local] update user[\(user.id)](\(user.username)) mute state: \(!isMuting)")
|
|
||||||
return MastodonMuteContext(
|
return MastodonMuteContext(
|
||||||
sourceUserID: me.id,
|
sourceUserID: me.id,
|
||||||
targetUserID: user.id,
|
targetUserID: user.id,
|
||||||
|
@ -111,7 +108,6 @@ extension APIService {
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
result = .failure(error)
|
result = .failure(error)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(muteContext.targetUserID)](\(muteContext.targetUsername)) mute failure: \(error.localizedDescription)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try await managedObjectContext.performChanges {
|
try await managedObjectContext.performChanges {
|
||||||
|
@ -131,11 +127,9 @@ extension APIService {
|
||||||
networkDate: response.networkDate
|
networkDate: response.networkDate
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] update user[\(muteContext.targetUserID)](\(muteContext.targetUsername)) mute state: \(relationship.muting.debugDescription)")
|
|
||||||
case .failure:
|
case .failure:
|
||||||
// rollback
|
// rollback
|
||||||
user.update(isMuting: muteContext.isMuting, by: me)
|
user.update(isMuting: muteContext.isMuting, by: me)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Remote] rollback user[\(muteContext.targetUserID)](\(muteContext.targetUsername)) mute state")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import Combine
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
||||||
|
@ -24,7 +23,6 @@ extension APIService {
|
||||||
record: ManagedObjectRecord<Status>,
|
record: ManagedObjectRecord<Status>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
|
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
|
||||||
let logger = Logger(subsystem: "APIService", category: "Reblog")
|
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
|
|
||||||
// update repost state and retrieve repost context
|
// update repost state and retrieve repost context
|
||||||
|
@ -45,7 +43,6 @@ extension APIService {
|
||||||
isReblogged: isReblogged,
|
isReblogged: isReblogged,
|
||||||
rebloggedCount: rebloggedCount
|
rebloggedCount: rebloggedCount
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status reblog: \(!isReblogged), \(reblogCount)")
|
|
||||||
return reblogContext
|
return reblogContext
|
||||||
}
|
}
|
||||||
guard let reblogContext = _reblogContext else {
|
guard let reblogContext = _reblogContext else {
|
||||||
|
@ -65,7 +62,6 @@ extension APIService {
|
||||||
result = .success(response)
|
result = .success(response)
|
||||||
} catch {
|
} catch {
|
||||||
result = .failure(error)
|
result = .failure(error)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update reblog failure: \(error.localizedDescription)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update repost state
|
// update repost state
|
||||||
|
@ -92,12 +88,10 @@ extension APIService {
|
||||||
if reblogContext.isReblogged {
|
if reblogContext.isReblogged {
|
||||||
status.update(reblogsCount: max(0, status.reblogsCount - 1)) // undo API return count has delay. Needs -1 local
|
status.update(reblogsCount: max(0, status.reblogsCount - 1)) // undo API return count has delay. Needs -1 local
|
||||||
}
|
}
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): update status reblog: \(!reblogContext.isReblogged)")
|
|
||||||
case .failure:
|
case .failure:
|
||||||
// rollback
|
// rollback
|
||||||
status.update(reblogged: reblogContext.isReblogged, by: me)
|
status.update(reblogged: reblogContext.isReblogged, by: me)
|
||||||
status.update(reblogsCount: reblogContext.rebloggedCount)
|
status.update(reblogsCount: reblogContext.rebloggedCount)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): rollback status reblog")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import CommonOSLog
|
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
import CommonOSLog
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
extension APIService {
|
extension APIService {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
import CommonOSLog
|
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
import AlamofireImage
|
import AlamofireImage
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
@ -22,13 +21,11 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
|
|
||||||
if let bestAttemptContent = bestAttemptContent {
|
if let bestAttemptContent = bestAttemptContent {
|
||||||
// Modify the notification content here...
|
// Modify the notification content here...
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
||||||
|
|
||||||
let privateKey = AppSecret.default.notificationPrivateKey
|
let privateKey = AppSecret.default.notificationPrivateKey
|
||||||
let auth = AppSecret.default.notificationAuth
|
let auth = AppSecret.default.notificationAuth
|
||||||
|
|
||||||
guard let encodedPayload = bestAttemptContent.userInfo["p"] as? String else {
|
guard let encodedPayload = bestAttemptContent.userInfo["p"] as? String else {
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: invalid payload", ((#file as NSString).lastPathComponent), #line, #function)
|
|
||||||
contentHandler(bestAttemptContent)
|
contentHandler(bestAttemptContent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -36,13 +33,11 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
|
|
||||||
guard let encodedPublicKey = bestAttemptContent.userInfo["k"] as? String,
|
guard let encodedPublicKey = bestAttemptContent.userInfo["k"] as? String,
|
||||||
let publicKey = NotificationService.publicKey(encodedPublicKey: encodedPublicKey) else {
|
let publicKey = NotificationService.publicKey(encodedPublicKey: encodedPublicKey) else {
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: invalid public key", ((#file as NSString).lastPathComponent), #line, #function)
|
|
||||||
contentHandler(bestAttemptContent)
|
contentHandler(bestAttemptContent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let encodedSalt = bestAttemptContent.userInfo["s"] as? String else {
|
guard let encodedSalt = bestAttemptContent.userInfo["s"] as? String else {
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: invalid salt", ((#file as NSString).lastPathComponent), #line, #function)
|
|
||||||
contentHandler(bestAttemptContent)
|
contentHandler(bestAttemptContent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -75,10 +70,9 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
ImageDownloader.default.download(URLRequest(url: url), completion: { [weak self] response in
|
ImageDownloader.default.download(URLRequest(url: url), completion: { [weak self] response in
|
||||||
guard let _ = self else { return }
|
guard let _ = self else { return }
|
||||||
switch response.result {
|
switch response.result {
|
||||||
case .failure(let error):
|
case .failure(_):
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: download image %s fail: %s", ((#file as NSString).lastPathComponent), #line, #function, url.debugDescription, error.localizedDescription)
|
break
|
||||||
case .success(let image):
|
case .success(let image):
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: download image %s success", ((#file as NSString).lastPathComponent), #line, #function, url.debugDescription)
|
|
||||||
try? image.pngData()?.write(to: fileURL)
|
try? image.pngData()?.write(to: fileURL)
|
||||||
if let attachment = try? UNNotificationAttachment(identifier: filename, url: fileURL, options: nil) {
|
if let attachment = try? UNNotificationAttachment(identifier: filename, url: fileURL, options: nil) {
|
||||||
bestAttemptContent.attachments = [attachment]
|
bestAttemptContent.attachments = [attachment]
|
||||||
|
|
Loading…
Reference in New Issue