Solspace Freeform query for submission assets returns all site assets I'm attempting to query for all assets associated with a specific form submission like this, where 'submission' has been set based on a URL parameter:

{% for field in submission.fieldMetadata %}
    {% if field.type == "file" %}
        {% set assetId = attribute(submission, field.handle) %}
        {% set assets = craft.assets.id(assetId).all() %}
           {% for asset in assets %}
                {% if asset %}
                    {% if asset.kind == "image" %}
                        &lt;img src='{{ asset.url }}'&gt;
                    {% endif %}
                {% endif %}
            {% endfor %}
    {% endif %}
{% endfor %}


The above code returns all site assets rather than just the assets associated with the submission. All other fields associated with the submission are returned correctly. Is this a bug or is my template incorrect?
The following template code resolved this issue for me:

{% for field in submission.fieldMetadata %}
     {% if field.type == "file" %}
        {% set assetIds = attribute(submission, field.handle).value %}
        {% if assetIds %}
           {% for assetId in assetIds %}
              {% set asset = craft.assets.id(assetId).one() %}
              {% if asset %}
                 {% if asset.kind == "image" %}
                    &lt;img src="{{ asset.url }}" /&gt;
                 {% else %}
                    &lt;a href="{{ asset.url }}"&gt;{{ asset.filename }}&lt;/a&gt;
                 {% endif %}
              {% endif %}
           {% endfor %}
        {% endif %}

     {% else %}
        {{ attribute(submission, field.handle) }}
     {% endif %}
{% endfor %}