Ejemplo n.º 1
0
func apnsresToError(apnsres *common.APNSResult, psp *push.PushServiceProvider, dp *push.DeliveryPoint) push.PushError {
	var err push.PushError
	switch apnsres.Status {
	case 0:
		err = nil
	case 1:
		err = push.NewBadDeliveryPointWithDetails(dp, "Processing Error")
	case 2:
		err = push.NewBadDeliveryPointWithDetails(dp, "Missing Device Token")
	case 3:
		err = push.NewBadNotificationWithDetails("Missing topic")
	case 4:
		err = push.NewBadNotificationWithDetails("Missing payload")
	case 5:
		err = push.NewBadNotificationWithDetails("Invalid token size")
	case 6:
		err = push.NewBadNotificationWithDetails("Invalid topic size")
	case 7:
		err = push.NewBadNotificationWithDetails("Invalid payload size")
	case 8:
		// err = NewBadDeliveryPointWithDetails(req.dp, "Invalid Token")
		// This token is invalid, we should unsubscribe this device.
		err = push.NewUnsubscribeUpdate(psp, dp)
	default:
		err = push.NewErrorf("Unknown Error: %d", apnsres.Status)
	}
	return err
}
Ejemplo n.º 2
0
func processFeedback(psp *push.PushServiceProvider, dpCache *cache.Cache, errChan chan<- push.PushError) {
	keys := receiveFeedback(psp)
	for _, token := range keys {
		dpif := dpCache.Delete(token)
		if dpif == nil {
			continue
		}
		if dp, ok := dpif.(*push.DeliveryPoint); ok {
			err := push.NewUnsubscribeUpdate(psp, dp)
			errChan <- err
		}
	}
}