mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2026-04-29 03:10:04 +00:00
first
This commit is contained in:
74
http/response/api/peer.go
Normal file
74
http/response/api/peer.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package api
|
||||
|
||||
import "Gwen/model"
|
||||
|
||||
/*
|
||||
GroupPeerPayload
|
||||
https://github.com/rustdesk/rustdesk/blob/master/flutter/lib/common/hbbs/hbbs.dart#L64
|
||||
|
||||
String id = '';
|
||||
Map<String, dynamic> info = {};
|
||||
int? status;
|
||||
String user = '';
|
||||
String user_name = '';
|
||||
String note = '';
|
||||
|
||||
PeerPayload.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'] ?? '',
|
||||
info = (json['info'] is Map<String, dynamic>) ? json['info'] : {},
|
||||
status = json['status'],
|
||||
user = json['user'] ?? '',
|
||||
user_name = json['user_name'] ?? '',
|
||||
note = json['note'] ?? '';
|
||||
|
||||
static Peer toPeer(GroupPeerPayload p) {
|
||||
return Peer.fromJson({
|
||||
"id": p.id,
|
||||
'loginName': p.user_name,
|
||||
"username": p.info['username'] ?? '',
|
||||
"platform": _platform(p.info['os']),
|
||||
"hostname": p.info['device_name'],
|
||||
});
|
||||
}
|
||||
*/
|
||||
type GroupPeerPayload struct {
|
||||
Id string `json:"id"`
|
||||
Info *PeerPayloadInfo `json:"info"`
|
||||
Status int `json:"status"`
|
||||
User string `json:"user"`
|
||||
UserName string `json:"user_name"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
type PeerPayloadInfo struct {
|
||||
DeviceName string `json:"device_name"`
|
||||
Os string `json:"os"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
func (gpp *GroupPeerPayload) FromAddressBook(a *model.AddressBook, username string) {
|
||||
gpp.Id = a.Id
|
||||
os := a.Platform
|
||||
if a.Platform == "Mac OS" {
|
||||
os = "MacOS"
|
||||
}
|
||||
gpp.Info = &PeerPayloadInfo{
|
||||
DeviceName: a.Hostname,
|
||||
Os: os,
|
||||
Username: a.Username,
|
||||
}
|
||||
gpp.UserName = username
|
||||
}
|
||||
|
||||
//func (gpp *GroupPeerPayload) FromPeer(p *model.Peer) {
|
||||
// gpp.Id = p.Id
|
||||
// gpp.Info = &PeerPayloadInfo{
|
||||
// DeviceName: p.Hostname,
|
||||
// Os: p.Os,
|
||||
// Username: p.Username,
|
||||
// }
|
||||
// gpp.Note = ""
|
||||
// if p.User.Id != 0 {
|
||||
// //gpp.User = p.User.Username
|
||||
// gpp.UserName = p.User.Username
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user