BIG ASS COMMIT
This commit is contained in:
@ -17,16 +17,13 @@
|
||||
package whatsappExt
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"maunium.net/go/mautrix-whatsapp/types"
|
||||
)
|
||||
|
||||
type CreateGroupResponse struct {
|
||||
Status int `json:"status"`
|
||||
GroupID types.WhatsAppID `json:"gid"`
|
||||
Participants map[types.WhatsAppID]struct {
|
||||
Status int `json:"status"`
|
||||
GroupID types.GroupMeID `json:"gid"`
|
||||
Participants map[types.GroupMeID]struct {
|
||||
Code string `json:"code"`
|
||||
} `json:"participants"`
|
||||
|
||||
@ -34,35 +31,36 @@ type CreateGroupResponse struct {
|
||||
}
|
||||
|
||||
type actualCreateGroupResponse struct {
|
||||
Status int `json:"status"`
|
||||
GroupID types.WhatsAppID `json:"gid"`
|
||||
Participants []map[types.WhatsAppID]struct {
|
||||
Status int `json:"status"`
|
||||
GroupID types.GroupMeID `json:"gid"`
|
||||
Participants []map[types.GroupMeID]struct {
|
||||
Code string `json:"code"`
|
||||
} `json:"participants"`
|
||||
}
|
||||
|
||||
func (ext *ExtendedConn) CreateGroup(subject string, participants []types.WhatsAppID) (*CreateGroupResponse, error) {
|
||||
respChan, err := ext.Conn.CreateGroup(subject, participants)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var resp CreateGroupResponse
|
||||
var actualResp actualCreateGroupResponse
|
||||
resp.Source = <-respChan
|
||||
fmt.Println(">>>>>>", resp.Source)
|
||||
err = json.Unmarshal([]byte(resp.Source), &actualResp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Status = actualResp.Status
|
||||
resp.GroupID = actualResp.GroupID
|
||||
resp.Participants = make(map[types.WhatsAppID]struct {
|
||||
Code string `json:"code"`
|
||||
})
|
||||
for _, participantMap := range actualResp.Participants {
|
||||
for jid, status := range participantMap {
|
||||
resp.Participants[jid] = status
|
||||
}
|
||||
}
|
||||
return &resp, nil
|
||||
func (ext *ExtendedConn) CreateGroup(subject string, participants []types.GroupMeID) (*CreateGroupResponse, error) {
|
||||
// respChan, err := ext.Conn.CreateGroup(subject, participants)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// var resp CreateGroupResponse
|
||||
// var actualResp actualCreateGroupResponse
|
||||
// resp.Source = <-respChan
|
||||
// fmt.Println(">>>>>>", resp.Source)
|
||||
// err = json.Unmarshal([]byte(resp.Source), &actualResp)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// resp.Status = actualResp.Status
|
||||
// resp.GroupID = actualResp.GroupID
|
||||
// resp.Participants = make(map[types.GroupMeID]struct {
|
||||
// Code string `json:"code"`
|
||||
// })
|
||||
// for _, participantMap := range actualResp.Participants {
|
||||
// for jid, status := range participantMap {
|
||||
// resp.Participants[jid] = status
|
||||
// }
|
||||
// }
|
||||
// return &resp, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user