Add getAccount XCB action

This commit is contained in:
Shadowfacts 2018-09-25 21:20:34 -04:00
parent e082076a23
commit 0bfc96fe38
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 18 additions and 1 deletions

View File

@ -17,6 +17,7 @@ enum XCBActionType: String {
case reblogStatus
// Accounts
case showAccount
case getAccount
case getCurrentUser
case followUser

View File

@ -239,6 +239,21 @@ struct XCBActions {
}
}
static func getAccount(_ url: XCallbackURL, _ session: XCBSession, _ silent: Bool?) {
getAccount(from: url, session: session) { (account) in
session.complete(with: .success, additionalData: [
"username": account.acct,
"displayName": account.displayName,
"locked": account.locked.description,
"followers": account.followersCount.description,
"following": account.followingCount.description,
"url": account.url.absoluteString,
"avatarURL": account.avatar.absoluteString,
"headerURL": account.header.absoluteString
])
}
}
static func getCurrentUser(_ url: XCallbackURL, _ session: XCBSession, _ silent: Bool?) {
let account = MastodonController.shared.account!
session.complete(with: .success, additionalData: [
@ -249,7 +264,7 @@ struct XCBActions {
"following": account.followingCount.description,
"url": account.url.absoluteString,
"avatarURL": account.avatar.absoluteString,
"headerURL": account.header.absoluteString,
"headerURL": account.header.absoluteString
])
}

View File

@ -19,6 +19,7 @@ class XCBManager {
XCallbackURLSpec(type: .reblogStatus, arguments: ["statusID": true, "statusURL": true], canRunSilently: true, action: XCBActions.reblogStatus),
// Accounts
XCallbackURLSpec(type: .showAccount, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: false, action: XCBActions.showAccount),
XCallbackURLSpec(type: .getAccount, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: false, action: XCBActions.getAccount),
XCallbackURLSpec(type: .getCurrentUser, arguments: [:], canRunSilently: false, action: XCBActions.getCurrentUser),
XCallbackURLSpec(type: .followUser, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: true, action: XCBActions.followUser)
]