UOA_SENDWEBHOOK::legacy_meta_data( $recipe_data )

Support legacy data structure.


Source

File: src/integrations/uncanny-automator/actions/uoa-sendwebhook.php

	public function legacy_meta_data( $recipe_data ) {
		if ( ! empty( $recipe_data['recipes_object'] ) ) {
			foreach ( $recipe_data['recipes_object'] as $recipe_key => $recipe ) {
				if ( 'trash' !== $recipe['post_status'] ) {
					if ( ! empty( $recipe['actions'] ) ) {
						foreach ( $recipe['actions'] as $action_key => $action ) {
							if ( $this->action_code === $action['meta']['code'] ) {
								if ( isset( $action['meta']['WEBHOOKURL'] ) && ! isset( $action['meta']['WEBHOOK_URL'] ) ) {
									$recipe_data['recipes_object'][ $recipe_key ]['actions'][ $action_key ]['meta']['WEBHOOK_URL'] = $action['meta']['WEBHOOKURL'];
								}
								if ( isset( $action['meta']['KEY1'] ) && ! isset( $action['meta']['WEBHOOK_FIELDS'] ) ) {
									$webhook_field = array();
									for ( $i = 1; $i <= self::$number_of_keys; $i ++ ) {
										if ( isset( $action['meta'][ 'KEY' . $i ] ) && ! empty( $action['meta'][ 'KEY' . $i ] ) ) {
											$webhook_field[] = [
												'KEY'   => $action['meta'][ 'KEY' . $i ],
												'VALUE' => $action['meta'][ 'VALUE' . $i ],
											];
										}
									}
									$recipe_data['recipes_object'][ $recipe_key ]['actions'][ $action_key ]['meta']['WEBHOOK_FIELDS'] = json_encode( $webhook_field );
								}
								if ( ! isset( $action['meta']['ACTION_EVENT'] ) ) {
									$recipe_data['recipes_object'][ $recipe_key ]['actions'][ $action_key ]['meta']['ACTION_EVENT'] = 'POST';
								}
							}
						}
					}
				}
			}
		}
		return $recipe_data;
	}