// Return a list of ChatMessages spoken in room
502986
func GetRoomMessages(room int) ([]*ChatMessage, error) {
	var messages []*ChatMessage

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

	return messages, err
}
534436
func (c *ChatRPC) ChatLeftConversation(
	_ context.Context, _ chat1.ChatLeftConversationArg) error {
	return nil
}
1036840
func ListMessages(c *messagebird.Client, conversationID string, options *ListOptions) (*MessageList, error) {
	query := paginationQuery(options)
	uri := fmt.Sprintf("%s/%s/%s?%s", path, conversationID, messagesPath, query)

	messageList := &MessageList{}
	if err := request(c, messageList, http.MethodGet, uri, nil); err != nil {
		return nil, err
	}

	return messageList, nil
}
158482
func Messages(
	bot reddit.Bot,
	kill <-chan bool,
	errs chan<- error,
) (
	<-chan *reddit.Message,
	error,
) {
	onlyMessages := make(chan *reddit.Message)

	messages, err := inboxStream(bot, kill, errs, "inbox")
	go func() {
		for m := range messages {
			if !m.WasComment {
				onlyMessages <- m
			}
		}
	}()

	return onlyMessages, err
}
21357
func (r *Room) Message(ctx context.Context, msg *UserMessage) {
	logger := pitaya.GetDefaultLoggerFromCtx(ctx)
	err := pitaya.GroupBroadcast(ctx, "connector", "room", "onMessage", msg)
	if err != nil {
		logger.Error("Error broadcasting message")
		logger.Error(err)
	}
}
1179826
func List(c *messagebird.Client, msgListParams *ListParams) (*MessageList, error) {
	messageList := &MessageList{}
	params, err := paramsForMessageList(msgListParams)
	if err != nil {
		return messageList, err
	}

	if err := c.Request(messageList, http.MethodGet, path+"?"+params.Encode(), nil); err != nil {
		return nil, err
	}

	return messageList, nil
}
114656
func (c *chatServiceHandler) findConversation(ctx context.Context, channel ChatChannel) (chat1.ConversationLocal, []chat1.RateLimit, error) {
	var conv chat1.ConversationLocal
	var rlimits []chat1.RateLimit

	if channel.IsNil() {
		return conv, rlimits, errors.New("missing conversation specificer")
	}

	existing, existingRl, err := c.getExistingConvs(ctx, channel)
	if err != nil {
		return conv, rlimits, err
	}
	rlimits = append(rlimits, existingRl...)

	if len(existing) > 1 {
		return conv, rlimits, fmt.Errorf("multiple conversations matched %q", channel.Name)
	}
	if len(existing) == 0 {
		return conv, rlimits, fmt.Errorf("no conversations matched %q", channel.Name)
	}

	return existing[0], rlimits, 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
}
471079
func (s *MessageStore) Messages() (map[[33]byte][]lnwire.Message, error) {
	msgs := make(map[[33]byte][]lnwire.Message)
	err := s.db.View(func(tx *bbolt.Tx) error {
		messageStore := tx.Bucket(messageStoreBucket)
		if messageStore == nil {
			return ErrCorruptedMessageStore
		}

		return messageStore.ForEach(func(k, v []byte) error {
			var pubKey [33]byte
			copy(pubKey[:], k[:33])

			// Deserialize the message from its raw bytes and filter
			// out any which are not currently supported by the
			// store.
			msg, err := readMessage(v)
			if err == ErrUnsupportedMessage {
				return nil
			}
			if err != nil {
				return err
			}

			msgs[pubKey] = append(msgs[pubKey], msg)
			return nil
		})
	})
	if err != nil {
		return nil, err
	}

	return msgs, nil
}
1010659
func (o *Me) VNFCatalogs(info *bambou.FetchingInfo) (VNFCatalogsList, *bambou.Error) {

	var list VNFCatalogsList
	err := bambou.CurrentSession().FetchChildren(o, VNFCatalogIdentity, &list, info)
	return list, err
}
1286334
func GetScrollback(room int) ([]*ChatMessage, error) {
	var messages []*ChatMessage // apparently the ORM works fine with using this type (they're aliases after all)

	err := db.DB.Table("chat_messages").Where("room = ? AND deleted = FALSE", room).Order("id desc").Limit(20).Find(&messages).Error

	return messages, err
}
310360
func (r *Room) messageOtherClients(client *Client, msg *Message) {
	r.Lock()
	msg.From = client.Name
		
	for _, c := range r.clients {
		if c != client {
			c.out <- msg
		}
	}
	defer r.Unlock()
}
320491
func (a Authorizer) Messages(rw http.ResponseWriter, req *http.Request) []string {
	session, _ := a.cookiejar.Get(req, "messages")
	flashes := session.Flashes()
	session.Save(req, rw)
	var messages []string
	for _, val := range flashes {
		messages = append(messages, val.(string))
	}
	return messages
}
780962
func Conversations() echo.HandlerFunc {

	// swagger:route GET /me/pms me post pms getMePms
	//
	// Shows the list of the private conversation of the current user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: MePms

	return func(c echo.Context) error {
		if !rest.IsGranted("pms:read", c) {
			return rest.InvalidScopeResponse("pms:read", c)
		}

		me := c.Get("me").(*nerdz.User)
		conversations, e := me.Conversations()
		if e != nil {
			errstr := "Unable to fetch conversations for the specified user"
			c.JSON(http.StatusBadRequest, &rest.Response{
				HumanMessage: errstr,
				Message:      "me.Conversations error",
				Status:       http.StatusBadRequest,
				Success:      false,
			})
			return errors.New(errstr)
		}

		var conversationsTO []*nerdz.ConversationTO
		for _, c := range *conversations {
			conversationsTO = append(conversationsTO, c.GetTO(me))
		}
		return rest.SelectFields(conversationsTO, c)
	}
}
1324852
func List(c *messagebird.Client) (*HLRList, error) {
	hlrList := &HLRList{}
	if err := c.Request(hlrList, http.MethodGet, path, nil); err != nil {
		return nil, err
	}

	return hlrList, nil
}
933714
func (api *Client) GetConversationRepliesContext(ctx context.Context, params *GetConversationRepliesParameters) (msgs []Message, hasMore bool, nextCursor string, err error) {
	values := url.Values{
		"token":   {api.token},
		"channel": {params.ChannelID},
		"ts":      {params.Timestamp},
	}
	if params.Cursor != "" {
		values.Add("cursor", params.Cursor)
	}
	if params.Latest != "" {
		values.Add("latest", params.Latest)
	}
	if params.Limit != 0 {
		values.Add("limit", strconv.Itoa(params.Limit))
	}
	if params.Oldest != "" {
		values.Add("oldest", params.Oldest)
	}
	if params.Inclusive {
		values.Add("inclusive", "1")
	} else {
		values.Add("inclusive", "0")
	}
	response := struct {
		SlackResponse
		HasMore          bool `json:"has_more"`
		ResponseMetaData struct {
			NextCursor string `json:"next_cursor"`
		} `json:"response_metadata"`
		Messages []Message `json:"messages"`
	}{}

	err = api.postMethod(ctx, "conversations.replies", values, &response)
	if err != nil {
		return nil, false, "", err
	}

	return response.Messages, response.HasMore, response.ResponseMetaData.NextCursor, response.Err()
}
584270
func (api *Client) GetUsersInConversation(params *GetUsersInConversationParameters) ([]string, string, error) {
	return api.GetUsersInConversationContext(context.Background(), params)
}