webClient.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package api
  2. import (
  3. "github.com/lejianwen/rustdesk-api/v2/model"
  4. "time"
  5. )
  6. type WebClientPeerPayload struct {
  7. ViewStyle string `json:"view-style"`
  8. Tm int64 `json:"tm"`
  9. Info WebClientPeerInfoPayload `json:"info"`
  10. Tmppwd string `json:"tmppwd"`
  11. }
  12. type WebClientPeerInfoPayload struct {
  13. Username string `json:"username"`
  14. Hostname string `json:"hostname"`
  15. Platform string `json:"platform"`
  16. Hash string `json:"hash"`
  17. Id string `json:"id"`
  18. }
  19. func (wcpp *WebClientPeerPayload) FromAddressBook(a *model.AddressBook) {
  20. wcpp.ViewStyle = "shrink"
  21. //24小时前
  22. wcpp.Tm = time.Now().Add(-time.Hour * 24).UnixNano()
  23. wcpp.Info = WebClientPeerInfoPayload{
  24. Username: a.Username,
  25. Hostname: a.Hostname,
  26. Platform: a.Platform,
  27. Hash: a.Hash,
  28. }
  29. }
  30. func (wcpp *WebClientPeerPayload) FromShareRecord(sr *model.ShareRecord) {
  31. wcpp.ViewStyle = "shrink"
  32. //24小时前
  33. wcpp.Tm = time.Now().UnixNano()
  34. wcpp.Tmppwd = sr.Password
  35. wcpp.Info = WebClientPeerInfoPayload{
  36. Username: "",
  37. Hostname: "",
  38. Platform: "",
  39. Id: sr.PeerId,
  40. }
  41. }