(event *wps.WaveEvent)
| 42 | } |
| 43 | |
| 44 | func handleBadgeEvent(event *wps.WaveEvent) { |
| 45 | if event.Event != wps.Event_Badge { |
| 46 | return |
| 47 | } |
| 48 | var data baseds.BadgeEvent |
| 49 | err := utilfn.ReUnmarshal(&data, event.Data) |
| 50 | if err != nil { |
| 51 | log.Printf("badge store: error unmarshaling BadgeEvent: %v\n", err) |
| 52 | return |
| 53 | } |
| 54 | if data.ClearAll { |
| 55 | clearAllBadges() |
| 56 | return |
| 57 | } |
| 58 | if data.ORef == "" { |
| 59 | log.Printf("badge store: received badge event with empty oref\n") |
| 60 | return |
| 61 | } |
| 62 | oref, err := waveobj.ParseORef(data.ORef) |
| 63 | if err != nil { |
| 64 | log.Printf("badge store: error parsing oref %q: %v\n", data.ORef, err) |
| 65 | return |
| 66 | } |
| 67 | if oref.OType != waveobj.OType_Block && oref.OType != waveobj.OType_Tab { |
| 68 | log.Printf("badge store: can only handle block/tab orefs") |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | setBadge(oref, data) |
| 73 | } |
| 74 | |
| 75 | // cmpBadge compares two badges by priority then by badgeid (both descending). |
| 76 | // Returns 1 if a > b, -1 if a < b, 0 if equal. |
nothing calls this directly
no test coverage detected