Exemple #1
0
func (f *Controller) fetchNotifiedParticipantIds(c *models.Channel, pe *models.ParticipantEvent, eventName string) ([]int64, error) {
	notifiedParticipantIds := make([]int64, 0)

	// notify added/removed participants
	for _, participant := range pe.Participants {
		notifiedParticipantIds = append(notifiedParticipantIds, participant.AccountId)
	}

	// When a user is removed from a private channel notify all channel participants to
	// make them update their sidebar channel list.
	if eventName == RemovedFromChannelEventName {

		if c.TypeConstant == models.Channel_TYPE_PRIVATE_MESSAGE ||
			c.TypeConstant == models.Channel_TYPE_COLLABORATION {

			participantIds, err := c.FetchParticipantIds(&request.Query{})
			if err != nil {
				return notifiedParticipantIds, err
			}
			notifiedParticipantIds = append(notifiedParticipantIds, participantIds...)
		}
	}
	return notifiedParticipantIds, nil
}