user 6 yıl önce
ebeveyn
işleme
985725c1da

+ 2 - 2
lib/content-item.d.ts

@@ -1,7 +1,7 @@
 import { ContentParams } from "./content-params";
 export declare class ContentItem {
     data: ContentParams;
-    private id;
+    private hash;
     private type;
     private myTagsWithoutAll;
     private allLinks;
@@ -15,6 +15,6 @@ export declare class ContentItem {
     private fromContactId?;
     private toContactId?;
     private media?;
-    constructor(props: ContentParams);
+    constructor(hash: string, props: ContentParams);
     private formatCents;
 }

+ 2 - 2
lib/content-item.js

@@ -1,9 +1,9 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 class ContentItem {
-    constructor(props) {
+    constructor(hash, props) {
         this.data = props;
-        this.id = props.id;
+        this.hash = hash;
         this.type = props.type;
         if (props.myTags) {
             this.myTagsWithoutAll = props.myTags.filter(x => x !== 'all');

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


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

@@ -1,6 +1,5 @@
 import { ContentLink } from "./content-link";
 export interface ContentParams {
-    id: string;
     type: string;
     links?: ContentLink[];
     myTags?: string[];

+ 4 - 4
lib/index.js

@@ -314,14 +314,14 @@ class BankClient {
     }
     getContentItemByHash(hash) {
         return __awaiter(this, void 0, void 0, function* () {
-            if (!hash.startsWith('/ipfs/')) {
-                hash = '/ipfs/' + hash;
+            if (hash.startsWith('/ipfs/')) {
+                hash = hash.split('/').pop();
             }
             const contentParams = (yield this.webClient.requestJSON({
                 method: 'get',
-                url: this.ipfsUrlBase + hash + '/content.json'
+                url: this.ipfsUrlBase + '/ipfs/' + hash + '/content.json'
             }));
-            return new content_item_1.ContentItem(contentParams);
+            return new content_item_1.ContentItem(hash, contentParams);
         });
     }
     getItemsForCommaList(commaList) {

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


+ 3 - 3
src/content-item.ts

@@ -4,7 +4,7 @@ import { ContentParams } from "./content-params";
 export class ContentItem {
 
   public data: ContentParams;
-  private id: string;
+  private hash: string;
   private type: string;
   
   private myTagsWithoutAll: string[];
@@ -21,9 +21,9 @@ export class ContentItem {
   private toContactId?: string;
   private media?: string;
   
-  constructor(props: ContentParams) {
+  constructor(hash: string, props: ContentParams) {
     this.data = props;
-    this.id = props.id;
+    this.hash = hash;
     this.type = props.type;
     
     if (props.myTags) {

+ 0 - 1
src/content-params.ts

@@ -1,7 +1,6 @@
 import { ContentLink } from "./content-link";
 
 export interface ContentParams {
-    id: string;
     type: string;
     links?: ContentLink[];
     myTags?: string[];

+ 4 - 4
src/index.ts

@@ -306,14 +306,14 @@ export class BankClient {
     }
 
     public async getContentItemByHash(hash: string): Promise<ContentItem> {
-      if (!hash.startsWith('/ipfs/')) {
-        hash = '/ipfs/' + hash;
+      if (hash.startsWith('/ipfs/')) {
+        hash = hash.split('/').pop() as string;
       }
       const contentParams = (await this.webClient.requestJSON({
         method: 'get',
-        url: this.ipfsUrlBase + hash + '/content.json'
+        url: this.ipfsUrlBase + '/ipfs/' + hash + '/content.json'
       })) as ContentParams;
-      return new ContentItem(contentParams);
+      return new ContentItem(hash, contentParams);
     }
 
     private async getItemsForCommaList(commaList: string): Promise<any[]> {