// getFlashMessages retrieves flash messages from the request and clears the flash cookie if needed.
199642
func getFlashMessages(resp http.ResponseWriter, req *http.Request) []flashMessage {
	c, err := req.Cookie("flash")
	if err == http.ErrNoCookie {
		return nil
	}
	http.SetCookie(resp, &http.Cookie{Name: "flash", Path: "/", MaxAge: -1, Expires: time.Now().Add(-100 * 24 * time.Hour)})
	if err != nil {
		return nil
	}
	p, err := base64.URLEncoding.DecodeString(c.Value)
	if err != nil {
		return nil
	}
	var messages []flashMessage
	for _, s := range strings.Split(string(p), "\000") {
		idArgs := strings.Split(s, "\001")
		messages = append(messages, flashMessage{ID: idArgs[0], Args: idArgs[1:]})
	}
	return messages
}
996026
func GetMessageType(typ reflect.Type) (*MessageType, error) {
	typeRegistry.m.RLock()
	cached := typeRegistry.types[typ]
	typeRegistry.m.RUnlock()
	if cached != nil {
		return cached, nil
	}

	zero := reflect.Zero(typ) // (*Struct)(nil)
	name := proto.MessageName(zero.Interface().(proto.Message))
	if name == "" {
		return nil, fmt.Errorf("%q is not a registered proto message type", typ.Name())
	}

	typeRegistry.m.Lock()
	defer typeRegistry.m.Unlock()
	if typeRegistry.types == nil {
		typeRegistry.types = map[reflect.Type]*MessageType{}
	}

	strct := typ.Elem() // Struct{}
	props := proto.GetProperties(strct)

	fields := map[string]fieldDesc{}
	names := []string{}

	// Handle non-oneof fields.
	for _, prop := range props.Prop {
		prop := prop
		// Oneof wrapper types generated by Go protoc have no tags and should not
		// appear in the list of message fields. Oneofs are handled below based on
		// props.OneofTypes map.
		if prop.Tag == 0 {
			continue
		}
		f, ok := strct.FieldByName(prop.Name)
		if !ok {
			panic("property from proto.GetProperties is not defined in the go struct")
		}
		fields[prop.OrigName] = fieldDesc{
			typ:         f.Type,
			defaultable: true,
			onProtoReflection: func(msg reflect.Value, _ reflectionDirection) reflect.Value {
				return msg.FieldByName(prop.Name)
			},
		}
		names = append(names, prop.OrigName)
	}

	// Oneof fields are very special.
	//
	// Imagine we have the following message:
	//
	// message Msg {
	//   ...
	//   oneof wrapper {
	//     A field_a = 1;
	//     B field_b = 2;
	//   }
	// }
	//
	// Protoc will generate the following types for it:
	//
	// type Msg struct {
	//    ...
	//    Wrapper isMsg_Wrapper // assume index of this field in Msg struct is 7
	// }
	//
	// type Msg_FieldA struct {
	//    FieldA *A
	// }
	//
	// type Msg_FieldB struct {
	//    FieldB *B
	// }
	//
	// (where *Msg_FieldA and *Msg_FieldB implement isMsg_Wrapper interface)
	//
	// When examining this via 'props' we'll see 'wrapper' listed among
	// props.Prop. We skip it completely since we want to expose only 'a' and 'b'.
	//
	// Next we'll see props.OneofTypes to be a map:
	//
	// 'field_a': {
	//   Type: *testprotos.Msg_FieldA
	//   Field: 7
	//   Prop: <useless>
	// },
	// 'field_b': {
	//   Type: *testprotos.Msg_FieldB
	//   Field: 7
	//   Prop: <useless>
	// }
	//
	// (where 7, as mentioned above, is an index of Wrapper field in Msg go
	// struct).
	//
	// Important details here:
	//   * Names of the Go fields inside Msg_* structs are not mentioned anywhere,
	//     e.g. 'FieldA' is not mentioned. We workaround this by asserting that
	//     Msg_* structs have only one field and then just referring to this field
	//     by index 0.
	//   * Wrapper field index (7), can be used to associate a bunch of oneof
	//     alternatives with each other (e.g. when setting one, clear another).
	//     So we'll build a reverse map {7 -> ['field_a', 'field_b']} for this.
	oneofGroups := map[int]*oneofGroup{} // keyed by the field index
	for name, desc := range props.OneofTypes {
		ofg := oneofGroups[desc.Field]
		if ofg == nil {
			ofg = &oneofGroup{
				fieldIdx: desc.Field,
			}
			oneofGroups[desc.Field] = ofg
		}
		ofg.registerAlternative(name, desc)
	}
	for _, ofg := range oneofGroups {
		for name, fd := range ofg.fieldDescs() {
			fields[name] = fd
			names = append(names, name)
		}
	}

	sort.Strings(names)

	newTyp := &MessageType{
		name:       name,
		ptr:        typ,
		fields:     fields,
		fieldNames: names,
	}
	typeRegistry.types[typ] = newTyp
	return newTyp, nil
}
1300417
func getMessage(token []byte) interface{} {
	var data map[string]interface{}
	// unmarshal JSON encoded token into a map for
	err := json.Unmarshal(token, &data)
	if err != nil {
		return err
	}
	return decodeMessage(token, data)
}
686297
func (t *Tab) GetConsoleMessages(messageHandler ConsoleMessageFunc) {
	t.Subscribe("Console.messageAdded", t.defaultConsoleMessageAdded(messageHandler))
}
571269
func (p *PullRequestReviewDismissalRequest) GetMessage() string {
	if p == nil || p.Message == nil {
		return ""
	}
	return *p.Message
}
893413
func (srv *Server) getMessage() (interface{}, error) {
	var rawXMLMsgBytes []byte
	var err error
	if srv.isSafeMode {
		var encryptedXMLMsg message.EncryptedXMLMsg
		if err := xml.NewDecoder(srv.Request.Body).Decode(&encryptedXMLMsg); err != nil {
			return nil, fmt.Errorf("从body中解析xml失败,err=%v", err)
		}

		//验证消息签名
		timestamp := srv.Query("timestamp")
		srv.timestamp, err = strconv.ParseInt(timestamp, 10, 32)
		if err != nil {
			return nil, err
		}
		nonce := srv.Query("nonce")
		srv.nonce = nonce
		msgSignature := srv.Query("msg_signature")
		msgSignatureGen := util.Signature(srv.Token, timestamp, nonce, encryptedXMLMsg.EncryptedMsg)
		if msgSignature != msgSignatureGen {
			return nil, fmt.Errorf("消息不合法，验证签名失败")
		}

		//解密
		srv.random, rawXMLMsgBytes, err = util.DecryptMsg(srv.AppID, encryptedXMLMsg.EncryptedMsg, srv.EncodingAESKey)
		if err != nil {
			return nil, fmt.Errorf("消息解密失败, err=%v", err)
		}
	} else {
		rawXMLMsgBytes, err = ioutil.ReadAll(srv.Request.Body)
		if err != nil {
			return nil, fmt.Errorf("从body中解析xml失败, err=%v", err)
		}
	}

	srv.requestRawXMLMsg = rawXMLMsgBytes

	return srv.parseRequestMessage(rawXMLMsgBytes)
}
123310
func (api *Client) GetMessages(query ...*GetMessagesQuery) ([]*Message, error) {
	var options *GetMessagesQuery
	if len(query) > 0 {
		options = query[0]
	}
	result, _, err := api.makeRequest(http.MethodGet, api.concatUserPath(messagesPath), &[]*Message{}, options)
	if err != nil {
		return nil, err
	}
	return *(result.(*[]*Message)), nil
}
1352620
func (s *messageStoreImpl) Get() []interface{} {
	res := make([]interface{}, 0)

	s.lock.RLock()
	defer s.lock.RUnlock()

	for _, msg := range s.messages {
		if !msg.expired {
			res = append(res, msg.data)
		}
	}
	return res
}
1312944
func (l *Limiter) GetMessageContentType() string {
	l.RLock()
	defer l.RUnlock()
	return l.messageContentType
}
805444
func GetPlayerMessages(p *player.Player) ([]*ChatMessage, error) {
	var messages []*ChatMessage

	err := db.DB.Model(&ChatMessage{}).Where("player_id = ?", p.ID).Order("room, created_at").Find(&messages).Error

	return messages, err

}
1140339
func (v *Bonk) GetMessage() (o string) {
	if v != nil && v.Message != nil {
		return *v.Message
	}

	return
}
515145
func GetFlashObj(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, pointer interface{}) error {
	val, err := GetFlash(overseer, w, r, key)
	if err != nil {
		return errors.Wrap(err, "unable to get flash object")
	}

	return json.Unmarshal([]byte(val), pointer)
}
455621
func readMessages(r io.Reader, p []byte) error {
	for len(p) > 0 {
		n, err := r.Read(p)
		p = p[n:]
		if err != nil {
			return err
		}
	}
	return nil
}
937862
func (b *Broker) collectMessages(in <-chan Message) {
	for {
		msg := <-in
		b.queue.Push(&msg)
	}
}
1056548
func (p *PullRequestMergeResult) GetMessage() string {
	if p == nil || p.Message == nil {
		return ""
	}
	return *p.Message
}
1000294
func (c *Commit) GetMessage() string {
	if c == nil || c.Message == nil {
		return ""
	}
	return *c.Message
}
749061
func (m *Machine) GetUpgradeSeriesMessages() ([]string, bool, error) {
	lock, err := m.getUpgradeSeriesLock()
	if errors.IsNotFound(err) {
		// If the lock is not found here then there are no more messages
		return nil, true, nil
	}
	if err != nil {
		return nil, false, errors.Trace(err)
	}
	// finished means that a subsequent call to this method, while the
	// Machine Lock is of a similar Machine Status, would return no
	// additional messages (notifications). Since the value of this variable
	// is returned, callers may choose to close streams or stop watchers
	// based on this information.
	finished := lock.MachineStatus == model.UpgradeSeriesCompleted ||
		lock.MachineStatus == model.UpgradeSeriesPrepareCompleted
	// Filter seen messages
	unseenMessages := make([]UpgradeSeriesMessage, 0)
	for _, upgradeSeriesMessage := range lock.Messages {
		if !upgradeSeriesMessage.Seen {
			unseenMessages = append(unseenMessages, upgradeSeriesMessage)
		}
	}
	if len(unseenMessages) == 0 {
		return []string{}, finished, nil
	}
	sort.Slice(unseenMessages, func(i, j int) bool {
		return unseenMessages[i].Timestamp.Before(unseenMessages[j].Timestamp)
	})
	messages := make([]string, 0)
	for _, unseenMessage := range unseenMessages {
		messages = append(messages, unseenMessage.Message)
	}
	err = m.SetUpgradeSeriesMessagesAsSeen(lock.Messages)
	if err != nil {
		return nil, false, errors.Trace(err)
	}
	return messages, finished, nil
}