-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprofile_section.go
57 lines (45 loc) · 1.35 KB
/
profile_section.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
package facebook
import "sync"
// ProfileSection contains tokens for profile sections data, like About, Friends, etc.
type ProfileSection struct {
ActorID string `json:"actorID,omitempty"`
PreloaderID string `json:"preloaderID,omitempty"`
QueryID string `json:"queryID,omitempty"`
Variables *Variables `json:"variables,omitempty"`
collections []Collection
mutex *sync.Mutex
}
type Variables struct {
AppSectionFeedKey string `json:"appSectionFeedKey,omitempty"`
CollectionToken string `json:"collectionToken,omitempty"`
RawSectionToken string `json:"rawSectionToken,omitempty"`
Scale float64 `json:"scale,omitempty"`
SectionToken string `json:"sectionToken,omitempty"`
UserID string `json:"userID,omitempty"`
}
// Collection contains token for section data
type Collection struct {
TabKey string `json:"tab_key,omitempty"`
ID string `json:"id,omitempty"`
}
func newProfileSection() *ProfileSection {
return &ProfileSection{mutex: new(sync.Mutex)}
}
func (p *ProfileSection) getColl(tabKey string) Collection {
p.mutex.Lock()
var coll Collection
for _, c := range p.collections {
if c.TabKey == tabKey {
coll = c
break
}
}
p.mutex.Unlock()
return coll
}
func (p *ProfileSection) getVariables() Variables {
p.mutex.Lock()
vars := *p.Variables
p.mutex.Unlock()
return vars
}