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

Method startClient

wmiau.go:400–685  ·  view source on GitHub ↗
(userID string, textjid string, token string, kill chan bool)

Source from the content-addressed store, hash-verified

398 GetS3Manager().EnsureClientFromDB(userID)
399 }(txtid)
400 }
401 }
402 err = rows.Err()
403 if err != nil {
404 log.Error().Err(err).Msg("DB Problem")
405 }
406}
407
408func parseJID(arg string) (types.JID, bool) {
409 if arg == "" {
410 return types.JID{}, false
411 }
412 if arg[0] == '+' {
413 arg = arg[1:]
414 }
415 if !strings.ContainsRune(arg, '@') {
416 return types.NewJID(arg, types.DefaultUserServer), true
417 } else {
418 recipient, err := types.ParseJID(arg)
419 if err != nil {
420 log.Error().Err(err).Msg("Invalid JID")
421 return recipient, false
422 } else if recipient.User == "" {
423 log.Error().Err(err).Msg("Invalid JID no server specified")
424 return recipient, false
425 }
426 return recipient, true
427 }
428}
429
430// jidUserKey returns the phone/account part shared by users.jid and
431// whatsmeow_device.jid even when formats differ (380...:8@ vs 380...@).
432func jidUserKey(jid string) string {
433 if jid == "" {
434 return ""
435 }
436 userPart := strings.SplitN(jid, "@", 2)[0]
437 return strings.SplitN(userPart, ":", 2)[0]
438}
439
440// jidLookupCandidates builds JID variants to try with sqlstore.GetDevice before
441// falling back to account-key matching across all stored devices.
442func jidLookupCandidates(textjid string) []types.JID {
443 jid, ok := parseJID(textjid)
444 if !ok {
445 return nil
446 }
447
448 seen := make(map[string]struct{})
449 var candidates []types.JID
450 add := func(candidate types.JID) {
451 if candidate.IsEmpty() {
452 return
453 }
454 key := candidate.String()
455 if _, exists := seen[key]; exists {
456 return
457 }

Callers 2

ConnectMethod · 0.95
connectOnStartupMethod · 0.95

Calls 15

parseJIDFunction · 0.85
getPlatformTypeEnumFunction · 0.85
GetS3ManagerFunction · 0.85
updateUserInfoFunction · 0.85
sendEventWithWebHookFunction · 0.85
signalKillFunction · 0.85
deleteKillChannelFunction · 0.85
SetWhatsmeowClientMethod · 0.80
SetMyClientMethod · 0.80
StringMethod · 0.80
SetProxyMethod · 0.80
SetHTTPClientMethod · 0.80

Tested by

no test coverage detected