mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Show a dialog for new ADB key if using device.
This commit is contained in:
parent
e6c1de5194
commit
95347d91f0
9 changed files with 152 additions and 109 deletions
|
@ -7,6 +7,7 @@ var zmq = require('zmq')
|
|||
var Promise = require('bluebird')
|
||||
var _ = require('lodash')
|
||||
var request = Promise.promisifyAll(require('request'))
|
||||
var adbkit = require('adbkit')
|
||||
|
||||
var logger = require('../../util/logger')
|
||||
var wire = require('../../wire')
|
||||
|
@ -133,6 +134,12 @@ module.exports = function(options) {
|
|||
)
|
||||
})
|
||||
})
|
||||
.on(wire.JoinGroupByAdbFingerprintMessage, function(channel, message) {
|
||||
socket.emit('user.keys.adb.confirm', {
|
||||
title: message.comment
|
||||
, fingerprint: message.fingerprint
|
||||
})
|
||||
})
|
||||
.on(wire.LeaveGroupMessage, function(channel, message) {
|
||||
socket.emit('device.change', {
|
||||
important: true
|
||||
|
@ -254,6 +261,79 @@ module.exports = function(options) {
|
|||
.on('user.settings.reset', function() {
|
||||
dbapi.resetUserSettings(user.email)
|
||||
})
|
||||
.on('user.keys.adb.add', function(data) {
|
||||
return adbkit.util.parsePublicKey(data.key)
|
||||
.then(function(key) {
|
||||
return dbapi.lookupUsersByAdbKey(key.fingerprint)
|
||||
.then(function(cursor) {
|
||||
return cursor.toArray()
|
||||
})
|
||||
.then(function(users) {
|
||||
if (users.length) {
|
||||
throw new dbapi.DuplicateSecondaryIndexError()
|
||||
}
|
||||
else {
|
||||
return dbapi.insertUserAdbKey(user.email, {
|
||||
title: data.title
|
||||
, fingerprint: key.fingerprint
|
||||
})
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
socket.emit('user.keys.adb.added', {
|
||||
title: data.title
|
||||
, fingerprint: key.fingerprint
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(function() {
|
||||
push.send([
|
||||
wireutil.global
|
||||
, wireutil.envelope(new wire.AdbKeysUpdatedMessage())
|
||||
])
|
||||
})
|
||||
.catch(dbapi.DuplicateSecondaryIndexError, function() {
|
||||
// No-op
|
||||
})
|
||||
})
|
||||
.on('user.keys.adb.accept', function(data) {
|
||||
return dbapi.lookupUsersByAdbKey(data.fingerprint)
|
||||
.then(function(cursor) {
|
||||
return cursor.toArray()
|
||||
})
|
||||
.then(function(users) {
|
||||
if (users.length) {
|
||||
throw new dbapi.DuplicateSecondaryIndexError()
|
||||
}
|
||||
else {
|
||||
return dbapi.insertUserAdbKey(user.email, {
|
||||
title: data.title
|
||||
, fingerprint: data.fingerprint
|
||||
})
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
socket.emit('user.keys.adb.added', {
|
||||
title: data.title
|
||||
, fingerprint: data.fingerprint
|
||||
})
|
||||
})
|
||||
.then(function() {
|
||||
push.send([
|
||||
user.group
|
||||
, wireutil.envelope(new wire.AdbKeysUpdatedMessage())
|
||||
])
|
||||
})
|
||||
.catch(dbapi.DuplicateSecondaryIndexError, function() {
|
||||
// No-op
|
||||
})
|
||||
})
|
||||
.on('user.keys.adb.remove', function(data) {
|
||||
return dbapi.deleteUserAdbKey(user.email, data.fingerprint)
|
||||
.then(function() {
|
||||
socket.emit('user.keys.adb.removed', data)
|
||||
})
|
||||
})
|
||||
// Touch events
|
||||
.on('input.touchDown', function(channel, data) {
|
||||
push.send([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue