user 6 yıl önce
ebeveyn
işleme
58e9d90267
4 değiştirilmiş dosya ile 11 ekleme ve 1 silme
  1. 1 0
      lib/content-item.d.ts
  2. 4 0
      lib/content-item.js
  3. 1 1
      lib/content-item.js.map
  4. 5 0
      src/content-item.ts

+ 1 - 0
lib/content-item.d.ts

@@ -18,6 +18,7 @@ export declare class ContentItem {
     readonly fromContactId?: string;
     readonly toContactId?: string;
     readonly media?: string;
+    readonly relTargets: any;
     constructor(hash: string, props: ContentParams);
     private formatCents;
 }

+ 4 - 0
lib/content-item.js

@@ -25,6 +25,10 @@ class ContentItem {
         this.fromContactId = this.allLinks.filter(x => x.rel === '.from-contact-id').map(x => x.target)[0];
         this.toContactId = this.allLinks.filter(x => x.rel === '.to-contact-id').map(x => x.target)[0];
         this.media = this.allLinks.filter(x => x.rel === '.media').map(x => x.target)[0];
+        this.relTargets = this.allLinks.reduce((accum, link) => {
+            accum[link.rel] = link.target;
+            return accum;
+        }, {});
         if (this.fromTarget && this.toTarget && this.media) {
             this.repliable = true;
         }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
lib/content-item.js.map


+ 5 - 0
src/content-item.ts

@@ -22,6 +22,7 @@ export class ContentItem {
   public readonly fromContactId?: string;
   public readonly toContactId?: string;
   public readonly media?: string;
+  public readonly relTargets: any;
   
   constructor(hash: string, props: ContentParams) {
     this.data = props;
@@ -48,6 +49,10 @@ export class ContentItem {
     this.fromContactId = this.allLinks.filter(x => x.rel === '.from-contact-id').map(x => x.target)[0];
     this.toContactId = this.allLinks.filter(x => x.rel === '.to-contact-id').map(x => x.target)[0];
     this.media = this.allLinks.filter(x => x.rel === '.media').map(x => x.target)[0];
+    this.relTargets = this.allLinks.reduce((accum, link) => {
+      accum[link.rel] = link.target;
+      return accum;
+    }, {});
     if (this.fromTarget && this.toTarget && this.media) {
       this.repliable = true;
     } else {