// https://github.com/gogs/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user
967079
func CheckMyFollowing(c *context.APIContext) {
	target := GetUserByParams(c)
	if c.Written() {
		return
	}
	checkUserFollowing(c, c.User, target.ID)
}
242345
func (a *AuthServer) ValidateGithubAuthCallback(q url.Values) (*GithubAuthResponse, error) {
	re, err := a.validateGithubAuthCallback(q)
	if err != nil {
		a.EmitAuditEvent(events.UserSSOLoginFailure, events.EventFields{
			events.LoginMethod:        events.LoginMethodGithub,
			events.AuthAttemptSuccess: false,
			events.AuthAttemptErr:     err.Error(),
		})
	} else {
		a.EmitAuditEvent(events.UserSSOLogin, events.EventFields{
			events.EventUser:          re.Username,
			events.AuthAttemptSuccess: true,
			events.LoginMethod:        events.LoginMethodGithub,
		})
	}
	return re, err
}
1266927
func (p *PathObserver) Follow(path, hash string) {
	p.FollowSpec(PathSpec{Hash: hash, Path: path, Sequence: p.sequencer(path, hash)})
}
135855
func (u *user) check(ca checkArg) {
	var err error

	defer func() {
		u.ca.log.Debug("Check %s, err: %v", ca, err)
		ca.retCh <- err
	}()

	if err = u.repopulate(); err != nil {
		return
	}

	if !ca.loadDeleted && u.isDeleted {
		err = ErrUserDeleted
		return
	}

	if ca.username != nil {
		if err = u.checkUsername(*ca.username); err != nil {
			return
		}
	}

	if ca.kid != nil {
		if err = u.checkKey(*ca.kid); err != nil {
			return
		}
	}

	if ca.sibkeys != nil {
		if err = u.compareSibkeys(ca.sibkeys); err != nil {
			return
		}
	}

	if ca.subkeys != nil {
		if err = u.compareSubkeys(ca.subkeys); err != nil {
			return
		}
	}
}
264985
func (self *User) Watch(eventsChannel *EventChannel) error {
	self.stop = make(chan struct{})
	go func() {
		for {
			select {
			case event := <-eventsChannel.channel:
				err := self.alert(event)
				if err != nil {
					log.Warningf("Failed to process watch event: %v", err)
				}
			case <-self.stop:
				log.Info("user watcher exiting")
				return
			}
		}
	}()
	return nil
}
738373
func (n navigator) Followf(rel string, params P) navigator {
	relations := append([]relation{}, n.path...)
	relations = append(relations, relation{rel: rel, params: params})

	return navigator{
		HttpClient: n.HttpClient,
		path:       relations,
		rootUri:    n.rootUri,
	}
}
865778
func (self *HttpClient) checkRedirect(req *http.Request, via []*http.Request) error {
	if !self.FollowRedirects {
		// don't follow redirects if explicitly disabled
		return NoRedirect
	}

	if req.Method == "HEAD" && !self.HeadRedirects {
		// don't follow redirects on a HEAD request
		return NoRedirect
	}

	DebugLog(self.Verbose).Println("REDIRECT:", len(via), req.URL)
	if len(req.Cookies()) > 0 {
		DebugLog(self.Verbose).Println("COOKIES:", req.Cookies())
	}

	if len(via) >= 10 {
		return TooManyRedirects
	}

	if len(via) > 0 {
		last := via[len(via)-1]
		if len(last.Cookies()) > 0 {
			DebugLog(self.Verbose).Println("LAST COOKIES:", last.Cookies())
		}
	}

	// TODO: check for same host before adding headers
	self.addHeaders(req, nil)
	return nil
}
1047910
func isFollowingForReview(mctx libkb.MetaContext, assertion string) (isFollowing bool, err error) {
	// The 'following' check blocks sending, and is not that important, so impose a timeout.
	var cancel func()
	mctx, cancel = mctx.WithTimeout(time.Second * 5)
	defer cancel()
	err = mctx.G().GetFullSelfer().WithSelf(mctx.Ctx(), func(u *libkb.User) error {
		idTable := u.IDTable()
		if idTable == nil {
			return nil
		}
		targetUsername := libkb.NewNormalizedUsername(assertion)
		for _, track := range idTable.GetTrackList() {
			if trackedUsername, err := track.GetTrackedUsername(); err == nil {
				if trackedUsername.Eq(targetUsername) {
					isFollowing = true
					return nil
				}
			}
		}
		return nil
	})
	return isFollowing, err
}
474869
func (bow *Browser) shouldRedirect(req *http.Request, _ []*http.Request) error {
	if bow.attributes[FollowRedirects] {
		req.Header.Set("User-Agent", bow.userAgent)
		return nil
	}
	return errors.NewLocation(
		"Redirects are disabled. Cannot follow '%s'.", req.URL.String())
}
378953
func (act *Activity) Following() *FollowingActivity {
	insta := act.inst
	nact := &FollowingActivity{inst: insta}
	return nact
}
991531
func (users *Users) Next() bool {
	if users.err != nil {
		return false
	}

	insta := users.inst
	endpoint := users.endpoint

	body, err := insta.sendRequest(
		&reqOptions{
			Endpoint: endpoint,
			Query: map[string]string{
				"max_id":             users.NextID,
				"ig_sig_key_version": goInstaSigKeyVersion,
				"rank_token":         insta.rankToken,
			},
		},
	)
	if err == nil {
		usrs := Users{}
		err = json.Unmarshal(body, &usrs)
		if err == nil {
			*users = usrs
			if !usrs.BigList || usrs.NextID == "" {
				users.err = ErrNoMore
			}
			users.inst = insta
			users.endpoint = endpoint
			users.setValues()
			return true
		}
	}
	users.err = err
	return false
}
926546
func (c *Callbacks) OnCDOTAUserMsg_GlyphAlert(fn func(*dota.CDOTAUserMsg_GlyphAlert) error) {
	c.onCDOTAUserMsg_GlyphAlert = append(c.onCDOTAUserMsg_GlyphAlert, fn)
}
239813
func (m *Mux) Follow(r io.ReadCloser, buffer string, msgID logagg.MsgID, config *Config) *LogStream {
	hdr := &rfc5424.Header{
		Hostname: []byte(config.HostID),
		AppName:  []byte(config.AppID),
		MsgID:    []byte(msgID),
	}
	if config.JobType != "" {
		hdr.ProcID = []byte(config.JobType + "." + config.JobID)
	} else {
		hdr.ProcID = []byte(config.JobID)
	}

	s := &LogStream{
		m:    m,
		log:  r,
		done: make(chan struct{}),
	}
	s.closed.Store(false)

	m.jobsMtx.Lock()
	defer m.jobsMtx.Unlock()
	// set up the WaitGroup so that subscribers can track when the job fds have closed
	wg, ok := m.jobWaits[config.JobID]
	if !ok {
		wg = &sync.WaitGroup{}
		m.jobWaits[config.JobID] = wg
	}
	wg.Add(1)
	if !ok {
		// we created the wg, so create a goroutine to clean up
		go func() {
			wg.Wait()
			m.jobsMtx.Lock()
			defer m.jobsMtx.Unlock()
			delete(m.jobWaits, config.JobID)
		}()
	}

	// if there is a jobStart channel, a subscriber is waiting for the WaitGroup
	// to be created, signal it.
	if ch, ok := m.jobStarts[config.JobID]; ok {
		close(ch)
		delete(m.jobStarts, config.JobID)
	}

	go s.follow(r, buffer, config.AppID, hdr, wg)
	return s
}
440808
func (u *UserLDAPMapping) GetFollowersURL() string {
	if u == nil || u.FollowersURL == nil {
		return ""
	}
	return *u.FollowersURL
}
814003
func (u *User) GetFollowing(page int) ([]*User, error) {
	users := make([]*User, 0, ItemsPerPage)
	sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.user_id=?", u.ID)
	if setting.UsePostgreSQL {
		sess = sess.Join("LEFT", "follow", `"user".id=follow.follow_id`)
	} else {
		sess = sess.Join("LEFT", "follow", "user.id=follow.follow_id")
	}
	return users, sess.Find(&users)
}
1283340
func (f *FollowersService) All(uri *Hyperlink, uriParams M) (followers []User, result *Result) {
	url, err := ExpandWithDefault(uri, &CurrentFollowerUrl, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}

	result = f.client.get(url, &followers)
	return
}
307953
func (account *Account) Followers() *Users {
	endpoint := fmt.Sprintf(urlFollowers, account.ID)
	users := &Users{}
	users.inst = account.inst
	users.endpoint = endpoint
	return users
}