diff --git a/app/definitions/IThread.ts b/app/definitions/IThread.ts index cc9271c8c..3116a502f 100644 --- a/app/definitions/IThread.ts +++ b/app/definitions/IThread.ts @@ -5,13 +5,7 @@ import { IAttachment } from './IAttachment'; import { IEditedBy, IUserChannel, IUserMention, IUserMessage } from './IMessage'; import { IReaction } from './IReaction'; import { SubscriptionType } from './ISubscription'; - -export interface IUrl { - title: string; - description: string; - image: string; - url: string; -} +import { IUrl } from './IUrl'; interface IFileThread { _id: string; diff --git a/app/definitions/IUrl.ts b/app/definitions/IUrl.ts index 9b72fda26..3e613bab3 100644 --- a/app/definitions/IUrl.ts +++ b/app/definitions/IUrl.ts @@ -1,6 +1,49 @@ export interface IUrl { + _id: number; title: string; description: string; image: string; url: string; } + +export interface IUrlFromServer { + url: string; + meta: { + pageTitle: string; + description: string; + fbAppId: string; + twitterImageSrc: string; + twitterSite: string; + twitterCard: string; + twitterTitle: string; + twitterDescription: string; + ogImage: string; + ogImageAlt: string; + ogImageWidth: string; + ogImageHeight: string; + ogSiteName: string; + ogType: string; + ogTitle: string; + ogUrl: string; + ogDescription: string; + title: string; + oembedTitle: string; + oembedAuthorName: string; + twitterImage: string; + oembedThumbnailUrl: string; + }; + headers: { + contentType: string; + }; + parsedUrl: { + host: string; + hash: any; + pathname: string; + protocol: string; + port: any; + query: any; + search: any; + hostname: string; + }; + ignoreParse: boolean; +} diff --git a/app/definitions/index.ts b/app/definitions/index.ts index 9512c7cf9..c11e91b1a 100644 --- a/app/definitions/index.ts +++ b/app/definitions/index.ts @@ -23,6 +23,7 @@ export * from './ILoggedUser'; export * from './IServerHistory'; export * from './IRocketChat'; export * from './ICertificate'; +export * from './IUrl'; export interface IBaseScreen, S extends string> { navigation: StackNavigationProp; diff --git a/app/lib/methods/helpers/parseUrls.js b/app/lib/methods/helpers/parseUrls.ts similarity index 75% rename from app/lib/methods/helpers/parseUrls.js rename to app/lib/methods/helpers/parseUrls.ts index 1d3dcff45..7ec2fa5ea 100644 --- a/app/lib/methods/helpers/parseUrls.js +++ b/app/lib/methods/helpers/parseUrls.ts @@ -1,8 +1,10 @@ -export default urls => +import { IUrl, IUrlFromServer } from '../../../definitions'; + +export default (urls: IUrlFromServer[]): IUrl[] => urls - .filter(url => url.meta && !url.ignoreParse) - .map((url, index) => { - const tmp = {}; + .filter((url: IUrlFromServer) => url.meta && !url.ignoreParse) + .map((url: IUrlFromServer, index) => { + const tmp: IUrl = {} as any; const { meta } = url; tmp._id = index; tmp.title = meta.ogTitle || meta.twitterTitle || meta.title || meta.pageTitle || meta.oembedTitle;