import { EmbedMetadata } from '../../../embed/embed-metadata.model';
import { Model } from '../../../model/model.service';

export class FiresidePostEmbed extends Model {
	url!: string;
	type!: string;
	extra_data!: string;
	metadata!: EmbedMetadata | null;
	is_processing!: boolean;

	/**
	 * Parsed data from the `extra_data` field.
	 */
	extraData: any;

	constructor(data: any = {}) {
		super(data);

		if (data.metadata) {
			this.metadata = new EmbedMetadata(data.metadata);
		}

		if (this.extra_data) {
			this.extraData = JSON.parse(data.extra_data);
		} else {
			this.extraData = {};
		}
	}
}

Model.create(FiresidePostEmbed);
