(s string)
| 37 | } |
| 38 | |
| 39 | func parseUpdate(s string) (id string, upd *mess.Update, err error) { |
| 40 | parts := strings.SplitN(s, ";", 2) |
| 41 | if len(parts) != 2 { |
| 42 | return "", nil, errors.New("updatepipe: mismatched parts count") |
| 43 | } |
| 44 | |
| 45 | upd = &mess.Update{} |
| 46 | dec := json.NewDecoder(strings.NewReader(unescapeName(parts[1]))) |
| 47 | dec.UseNumber() |
| 48 | err = dec.Decode(upd) |
| 49 | if err != nil { |
| 50 | return "", nil, fmt.Errorf("parseUpdate: %w", err) |
| 51 | } |
| 52 | |
| 53 | if val, ok := upd.Key.(json.Number); ok { |
| 54 | upd.Key, _ = strconv.ParseUint(val.String(), 10, 64) |
| 55 | } |
| 56 | |
| 57 | return parts[0], upd, nil |
| 58 | } |
| 59 | |
| 60 | func formatUpdate(myID string, upd mess.Update) (string, error) { |
| 61 | updBlob, err := json.Marshal(upd) |
no test coverage detected