-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
rpc_exim.go
64 lines (53 loc) · 1.88 KB
/
rpc_exim.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
// Export-Import for RPC for Teams
package teams
import (
"golang.org/x/net/context"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
)
func (t *Team) ExportToTeamPlusApplicationKeys(ctx context.Context, idTime keybase1.Time,
application keybase1.TeamApplication, includeKBFSKeys bool) (ret keybase1.TeamPlusApplicationKeys, err error) {
loadKeys := true
if t.IsPublic() {
// If it's a public team, only try to load application keys if
// we are a member. If we are not, we should still be able to
// get team details using this func (and get an empty key list).
role, err := t.myRole(ctx)
loadKeys = err == nil && role != keybase1.TeamRole_NONE
}
var applicationKeys []keybase1.TeamApplicationKey
if loadKeys {
keyFunc := t.AllApplicationKeys
if includeKBFSKeys {
keyFunc = t.AllApplicationKeysWithKBFS
}
applicationKeys, err = keyFunc(ctx, application)
if err != nil {
return ret, err
}
}
members, err := t.Members()
if err != nil {
return ret, err
}
var writers, onlyReaders, onlyRestrictedBots []keybase1.UserVersion
writers = append(writers, members.Writers...)
writers = append(writers, members.Admins...)
writers = append(writers, members.Owners...)
onlyReaders = append(onlyReaders, members.Readers...)
onlyReaders = append(onlyReaders, members.Bots...)
onlyRestrictedBots = append(onlyRestrictedBots, members.RestrictedBots...)
ret = keybase1.TeamPlusApplicationKeys{
Id: t.chain().GetID(),
Name: t.Name().String(),
Implicit: t.IsImplicit(),
Public: t.IsPublic(),
Application: application,
Writers: writers,
OnlyReaders: onlyReaders,
OnlyRestrictedBots: onlyRestrictedBots,
ApplicationKeys: applicationKeys,
}
return ret, nil
}