forked from shadowfacts/Tusker
Add getAccount XCB action
This commit is contained in:
parent
e082076a23
commit
0bfc96fe38
|
@ -17,6 +17,7 @@ enum XCBActionType: String {
|
||||||
case reblogStatus
|
case reblogStatus
|
||||||
// Accounts
|
// Accounts
|
||||||
case showAccount
|
case showAccount
|
||||||
|
case getAccount
|
||||||
case getCurrentUser
|
case getCurrentUser
|
||||||
case followUser
|
case followUser
|
||||||
|
|
||||||
|
|
|
@ -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?) {
|
static func getCurrentUser(_ url: XCallbackURL, _ session: XCBSession, _ silent: Bool?) {
|
||||||
let account = MastodonController.shared.account!
|
let account = MastodonController.shared.account!
|
||||||
session.complete(with: .success, additionalData: [
|
session.complete(with: .success, additionalData: [
|
||||||
|
@ -249,7 +264,7 @@ struct XCBActions {
|
||||||
"following": account.followingCount.description,
|
"following": account.followingCount.description,
|
||||||
"url": account.url.absoluteString,
|
"url": account.url.absoluteString,
|
||||||
"avatarURL": account.avatar.absoluteString,
|
"avatarURL": account.avatar.absoluteString,
|
||||||
"headerURL": account.header.absoluteString,
|
"headerURL": account.header.absoluteString
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ class XCBManager {
|
||||||
XCallbackURLSpec(type: .reblogStatus, arguments: ["statusID": true, "statusURL": true], canRunSilently: true, action: XCBActions.reblogStatus),
|
XCallbackURLSpec(type: .reblogStatus, arguments: ["statusID": true, "statusURL": true], canRunSilently: true, action: XCBActions.reblogStatus),
|
||||||
// Accounts
|
// Accounts
|
||||||
XCallbackURLSpec(type: .showAccount, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: false, action: XCBActions.showAccount),
|
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: .getCurrentUser, arguments: [:], canRunSilently: false, action: XCBActions.getCurrentUser),
|
||||||
XCallbackURLSpec(type: .followUser, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: true, action: XCBActions.followUser)
|
XCallbackURLSpec(type: .followUser, arguments: ["accountID": true, "accountURL": true, "acct": true], canRunSilently: true, action: XCBActions.followUser)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue