コード例 #1
0
func RejectInvite(u *url.URL, h http.Header, participant *models.ChannelParticipant, ctx *models.Context) (int, http.Header, interface{}, error) {

	query := ctx.OverrideQuery(request.GetQuery(u))
	participant.StatusConstant = models.ChannelParticipant_STATUS_LEFT
	cp, err := updateStatus(participant, query, ctx)
	if err != nil {
		return response.NewBadRequest(err)
	}

	if err := addLeaveActivity(query.Id, ctx.Client.Account.Id, cp); err != nil {
		return response.NewBadRequest(err)
	}

	ch := models.NewChannel()

	if err := ch.ById(query.Id); err != nil {
		return response.NewBadRequest(err)
	}

	go notifyParticipants(ch, models.ChannelParticipant_Removed_From_Channel_Event, []*models.ChannelParticipant{cp})

	return response.NewDefaultOK()
}
コード例 #2
0
func AcceptInvite(u *url.URL, h http.Header, participant *models.ChannelParticipant, ctx *models.Context) (int, http.Header, interface{}, error) {

	query := ctx.OverrideQuery(request.GetQuery(u))

	participant.StatusConstant = models.ChannelParticipant_STATUS_ACTIVE
	cp, err := updateStatus(participant, query, ctx)
	if err != nil {
		return response.NewBadRequest(err)
	}

	if err := addJoinActivity(query.Id, cp, 0); err != nil {
		return response.NewBadRequest(err)
	}

	ch := models.NewChannel()
	if err := ch.ById(query.Id); err != nil {
		return response.NewBadRequest(err)
	}

	go notifyParticipants(ch, models.ChannelParticipant_Added_To_Channel_Event, []*models.ChannelParticipant{cp})

	return response.NewDefaultOK()
}