MCPcopy Create free account
hub / github.com/asternic/wuzapi / SetGroupTopic

Method SetGroupTopic

handlers.go:5085–5140  ·  view source on GitHub ↗

Set group topic (description)

()

Source from the content-addressed store, hash-verified

5083 return
5084 }
5085}
5086
5087// add, remove, promote and demote members group
5088func (s *server) UpdateGroupParticipants() http.HandlerFunc {
5089
5090 type updateGroupParticipantsStruct struct {
5091 GroupJID string
5092 Phone []string
5093 // Action string // add, remove, promote, demote
5094 Action string
5095 }
5096
5097 return func(w http.ResponseWriter, r *http.Request) {
5098
5099 txtid := r.Context().Value("userinfo").(Values).Get("Id")
5100
5101 if clientManager.GetWhatsmeowClient(txtid) == nil {
5102 s.Respond(w, r, http.StatusInternalServerError, errors.New("no session"))
5103 return
5104 }
5105
5106 decoder := json.NewDecoder(r.Body)
5107 var t updateGroupParticipantsStruct
5108 err := decoder.Decode(&t)
5109 if err != nil {
5110 s.Respond(w, r, http.StatusBadRequest, errors.New("could not decode Payload"))
5111 return
5112 }
5113
5114 group, ok := parseJID(t.GroupJID)
5115 if !ok {
5116 s.Respond(w, r, http.StatusBadRequest, errors.New("could not parse Group JID"))
5117 return
5118 }
5119
5120 if len(t.Phone) < 1 {
5121 s.Respond(w, r, http.StatusBadRequest, errors.New("missing Phone in Payload"))
5122 return
5123 }
5124 // parse phone numbers
5125 phoneParsed := make([]types.JID, len(t.Phone))
5126 for i, phone := range t.Phone {
5127 phoneParsed[i], ok = parseJID(phone)
5128 if !ok {
5129 s.Respond(w, r, http.StatusBadRequest, errors.New("could not parse Phone"))
5130 return
5131 }
5132 }
5133
5134 if t.Action == "" {
5135 s.Respond(w, r, http.StatusBadRequest, errors.New("missing Action in Payload"))
5136 return
5137 }
5138
5139 // parse action
5140
5141 var action whatsmeow.ParticipantChange
5142 switch t.Action {

Callers 1

routesMethod · 0.95

Calls 4

RespondMethod · 0.95
parseJIDFunction · 0.85
GetMethod · 0.80
GetWhatsmeowClientMethod · 0.80

Tested by

no test coverage detected