Ver código fonte

gun working fine

rohit.gowda 5 anos atrás
pai
commit
aa51d08615

+ 248 - 155
app/src/providers/mock-provider/tweet.json

@@ -1,162 +1,255 @@
 [
+{
+  "created_at": "Wed Sep 25 19:54:41 +0000 2019",
+  "id": 1176948153297362947,
+  "id_str": "1176948153297362947",
+  "full_text": "Fgttgf",
+  "truncated": false,
+  "display_text_range": [
+    0,
+    6
+  ],
+  "entities":
   {
-    "created_at": "Wed Sep 25 19:54:41 +0000 2019",
-    "id": 1176948153297362947,
-    "id_str": "1176948153297362947",
-    "full_text": "Fgttgf",
-    "truncated": false,
-    "display_text_range": [
-      0,
-      6
-    ],
-    "entities": {
-      "hashtags": [],
-      "symbols": [],
-      "user_mentions": [],
-      "urls": []
-    },
-    "source": "<a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
-    "in_reply_to_status_id": null,
-    "in_reply_to_status_id_str": null,
-    "in_reply_to_user_id": null,
-    "in_reply_to_user_id_str": null,
-    "in_reply_to_screen_name": null,
-    "user": {
-      "id": 1176099783947235328,
-      "id_str": "1176099783947235328",
-      "name": "Thesis test",
-      "screen_name": "test_thesis",
-      "location": "",
-      "description": "",
-      "url": null,
-      "entities": {
-        "description": {
-          "urls": []
-        }
-      },
-      "protected": false,
-      "followers_count": 0,
-      "friends_count": 0,
-      "listed_count": 0,
-      "created_at": "Mon Sep 23 11:43:41 +0000 2019",
-      "favourites_count": 0,
-      "utc_offset": null,
-      "time_zone": null,
-      "geo_enabled": false,
-      "verified": false,
-      "statuses_count": 2,
-      "lang": null,
-      "contributors_enabled": false,
-      "is_translator": false,
-      "is_translation_enabled": false,
-      "profile_background_color": "F5F8FA",
-      "profile_background_image_url": null,
-      "profile_background_image_url_https": null,
-      "profile_background_tile": false,
-      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
-      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
-      "profile_link_color": "1DA1F2",
-      "profile_sidebar_border_color": "C0DEED",
-      "profile_sidebar_fill_color": "DDEEF6",
-      "profile_text_color": "333333",
-      "profile_use_background_image": true,
-      "has_extended_profile": false,
-      "default_profile": true,
-      "default_profile_image": true,
-      "following": false,
-      "follow_request_sent": false,
-      "notifications": false,
-      "translator_type": "none"
+    "hashtags": [],
+    "symbols": [],
+    "user_mentions": [],
+    "urls": []
+  },
+  "source": "<a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
+  "in_reply_to_status_id": null,
+  "in_reply_to_status_id_str": null,
+  "in_reply_to_user_id": null,
+  "in_reply_to_user_id_str": null,
+  "in_reply_to_screen_name": null,
+  "user":
+  {
+    "id": 1176099783947235328,
+    "id_str": "1176099783947235328",
+    "name": "Thesis test",
+    "screen_name": "test_thesis",
+    "location": "",
+    "description": "",
+    "url": null,
+    "entities":
+    {
+      "description":
+      {
+        "urls": []
+      }
     },
-    "geo": null,
-    "coordinates": null,
-    "place": null,
-    "contributors": null,
-    "is_quote_status": false,
-    "retweet_count": 0,
-    "favorite_count": 0,
-    "favorited": false,
-    "retweeted": false,
-    "lang": "tl"
+    "protected": false,
+    "followers_count": 0,
+    "friends_count": 0,
+    "listed_count": 0,
+    "created_at": "Mon Sep 23 11:43:41 +0000 2019",
+    "favourites_count": 0,
+    "utc_offset": null,
+    "time_zone": null,
+    "geo_enabled": false,
+    "verified": false,
+    "statuses_count": 2,
+    "lang": null,
+    "contributors_enabled": false,
+    "is_translator": false,
+    "is_translation_enabled": false,
+    "profile_background_color": "F5F8FA",
+    "profile_background_image_url": null,
+    "profile_background_image_url_https": null,
+    "profile_background_tile": false,
+    "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+    "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+    "profile_link_color": "1DA1F2",
+    "profile_sidebar_border_color": "C0DEED",
+    "profile_sidebar_fill_color": "DDEEF6",
+    "profile_text_color": "333333",
+    "profile_use_background_image": true,
+    "has_extended_profile": false,
+    "default_profile": true,
+    "default_profile_image": true,
+    "following": false,
+    "follow_request_sent": false,
+    "notifications": false,
+    "translator_type": "none"
+  },
+  "geo": null,
+  "coordinates": null,
+  "place": null,
+  "contributors": null,
+  "is_quote_status": false,
+  "retweet_count": 0,
+  "favorite_count": 0,
+  "favorited": false,
+  "retweeted": false,
+  "lang": "tl"
+},
+{
+  "created_at": "Wed Sep 29 19:54:41 +0000 2019",
+  "id": 1176948153297362947,
+  "id_str": "1176948153297362947",
+  "full_text": "Private tweet",
+  "private_tweet": true,
+  "truncated": false,
+  "display_text_range": [
+    0,
+    13
+  ],
+  "entities":
+  {
+    "hashtags": [],
+    "symbols": [],
+    "user_mentions": [],
+    "urls": []
   },
+  "source": "<a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
+  "in_reply_to_status_id": null,
+  "in_reply_to_status_id_str": null,
+  "in_reply_to_user_id": null,
+  "in_reply_to_user_id_str": null,
+  "in_reply_to_screen_name": null,
+  "user":
   {
-    "created_at": "Wed Sep 25 19:54:41 +0000 2019",
-    "id": 1176948153297362947,
-    "id_str": "1176948153297362947",
-    "full_text": "Providing mock tweets",
-    "truncated": false,
-    "display_text_range": [
-      0,
-      6
-    ],
-    "entities": {
-      "hashtags": [],
-      "symbols": [],
-      "user_mentions": [],
-      "urls": []
+    "id": 1176099783947235328,
+    "id_str": "1176099783947235328",
+    "name": "Thesis test",
+    "screen_name": "test_thesis",
+    "location": "",
+    "description": "tweet://1192026901956583424 #hybridOSN",
+    "url": null,
+    "entities":
+    {
+      
+      "description":
+      {
+        "urls": []
+      }
     },
-    "source": "<a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
-    "in_reply_to_status_id": null,
-    "in_reply_to_status_id_str": null,
-    "in_reply_to_user_id": null,
-    "in_reply_to_user_id_str": null,
-    "in_reply_to_screen_name": null,
-    "user": {
-      "id": 1176099783947235328,
-      "id_str": "1176099783947235328",
-      "name": "Thesis test",
-      "screen_name": "test_thesis",
-      "location": "",
-      "description": "",
-      "url": null,
-      "entities": {
-        "description": {
-          "urls": []
-        }
-      },
-      "protected": true,
-      "followers_count": 0,
-      "friends_count": 0,
-      "listed_count": 0,
-      "created_at": "Mon Sep 23 11:43:41 +0000 2019",
-      "favourites_count": 0,
-      "utc_offset": null,
-      "time_zone": null,
-      "geo_enabled": false,
-      "verified": false,
-      "statuses_count": 2,
-      "lang": null,
-      "contributors_enabled": false,
-      "is_translator": false,
-      "is_translation_enabled": false,
-      "profile_background_color": "333333",
-      "profile_background_image_url": null,
-      "profile_background_image_url_https": null,
-      "profile_background_tile": false,
-      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
-      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
-      "profile_link_color": "1DA1F2",
-      "profile_sidebar_border_color": "C0DEED",
-      "profile_sidebar_fill_color": "DDEEF6",
-      "profile_text_color": "F5F8FA",
-      "profile_use_background_image": true,
-      "has_extended_profile": false,
-      "default_profile": true,
-      "default_profile_image": true,
-      "following": false,
-      "follow_request_sent": false,
-      "notifications": false,
-      "translator_type": "none"
+    "protected": false,
+    "followers_count": 0,
+    "friends_count": 0,
+    "listed_count": 0,
+    "created_at": "Mon Sep 23 11:43:41 +0000 2019",
+    "favourites_count": 0,
+    "utc_offset": null,
+    "time_zone": null,
+    "geo_enabled": false,
+    "verified": false,
+    "statuses_count": 2,
+    "lang": null,
+    "contributors_enabled": false,
+    "is_translator": false,
+    "is_translation_enabled": false,
+    "profile_background_color": "F5F8FA",
+    "profile_background_image_url": null,
+    "profile_background_image_url_https": null,
+    "profile_background_tile": false,
+    "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+    "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+    "profile_link_color": "1DA1F2",
+    "profile_sidebar_border_color": "C0DEED",
+    "profile_sidebar_fill_color": "DDEEF6",
+    "profile_text_color": "333333",
+    "profile_use_background_image": true,
+    "has_extended_profile": false,
+    "default_profile": true,
+    "default_profile_image": true,
+    "following": false,
+    "follow_request_sent": false,
+    "notifications": false,
+    "translator_type": "none"
+  },
+  "geo": null,
+  "coordinates": null,
+  "place": null,
+  "contributors": null,
+  "is_quote_status": false,
+  "retweet_count": 0,
+  "favorite_count": 0,
+  "favorited": false,
+  "retweeted": false,
+  "lang": "tl"
+},
+{
+  "created_at": "Wed Sep 25 19:54:41 +0000 2019",
+  "id": 1176948153297362947,
+  "id_str": "1176948153297362947",
+  "full_text": "Providing mock tweets",
+  "truncated": false,
+  "display_text_range": [
+    0,
+    6
+  ],
+  "entities":
+  {
+    "hashtags": [],
+    "symbols": [],
+    "user_mentions": [],
+    "urls": []
+  },
+  "source": "<a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
+  "in_reply_to_status_id": null,
+  "in_reply_to_status_id_str": null,
+  "in_reply_to_user_id": null,
+  "in_reply_to_user_id_str": null,
+  "in_reply_to_screen_name": null,
+  "user":
+  {
+    "id": 1176099783947235328,
+    "id_str": "1176099783947235328",
+    "name": "Thesis test",
+    "screen_name": "test_thesis",
+    "location": "",
+    "description": "",
+    "url": null,
+    "entities":
+    {
+      "description":
+      {
+        "urls": []
+      }
     },
-    "geo": null,
-    "coordinates": null,
-    "place": null,
-    "contributors": null,
-    "is_quote_status": false,
-    "retweet_count": 0,
-    "favorite_count": 0,
-    "favorited": false,
-    "retweeted": false,
-    "lang": "tl"
-  }
-]
+    "protected": false,
+    "followers_count": 0,
+    "friends_count": 0,
+    "listed_count": 0,
+    "created_at": "Mon Sep 23 11:43:41 +0000 2019",
+    "favourites_count": 0,
+    "utc_offset": null,
+    "time_zone": null,
+    "geo_enabled": false,
+    "verified": false,
+    "statuses_count": 2,
+    "lang": null,
+    "contributors_enabled": false,
+    "is_translator": false,
+    "is_translation_enabled": false,
+    "profile_background_color": "F5F8FA",
+    "profile_background_image_url": null,
+    "profile_background_image_url_https": null,
+    "profile_background_tile": false,
+    "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+    "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+    "profile_link_color": "1DA1F2",
+    "profile_sidebar_border_color": "C0DEED",
+    "profile_sidebar_fill_color": "DDEEF6",
+    "profile_text_color": "333333",
+    "profile_use_background_image": true,
+    "has_extended_profile": false,
+    "default_profile": true,
+    "default_profile_image": true,
+    "following": false,
+    "follow_request_sent": false,
+    "notifications": false,
+    "translator_type": "none"
+  },
+  "geo": null,
+  "coordinates": null,
+  "place": null,
+  "contributors": null,
+  "is_quote_status": false,
+  "retweet_count": 0,
+  "favorite_count": 0,
+  "favorited": false,
+  "retweeted": false,
+  "lang": "tl"
+}]

+ 9 - 9
app/src/providers/p2p-database-gun/p2p-database-gun.ts

@@ -8,14 +8,14 @@ export class P2pDatabaseGunProvider {
   osnPrefix: string = "hybridOSN-v1.0.0";
 
   constructor() {
-    this.gun = Gun(["https://hybrid-osn.herokuapp.com/gun"]);
+    this.gun = Gun(["https://hosn-twitter-app.herokuapp.com/gun"]);
   }
 
   /**
    * Hashtags are stored without reference to the users to provide these information on an extra dashboard to twitter
    * @param hashtagEntity extracted hashtags
    */
-  public async publishHashtags(hashtagEntity): Promise<void> {
+  public async publishHashtags(hashtagEntity): Promise < void > {
     const timestamp = new Date().setHours(0, 0, 1, 0);
     const hashtagsSeparated = hashtagEntity
       .map(el => el.hashtag)
@@ -29,10 +29,10 @@ export class P2pDatabaseGunProvider {
       .put({ hashtags: hashtagsSeparated });
 
     this.gun
-      .get(this.osnPrefix)
-      .get("hashtags")
-      .get(timestamp)
-      .set(hashtags);
+    .get(this.osnPrefix)
+    .get("hashtags")
+    .get(timestamp)
+    .set(hashtags);
   }
 
   /**
@@ -63,7 +63,7 @@ export class P2pDatabaseGunProvider {
     userId,
     intervalStart,
     intervalEnd
-  ): Promise<object[]> {
+  ): Promise < object[] > {
     const privateTweets = await this.gun
       .get(this.osnPrefix)
       .get("tweets")
@@ -73,8 +73,8 @@ export class P2pDatabaseGunProvider {
     if (privateTweets) {
       const entries = await Promise.all(
         Object.keys(privateTweets)
-          .filter(key => key !== "_")
-          .map(key => this.gun.get(key).then())
+        .filter(key => key !== "_")
+        .map(key => this.gun.get(key).then())
       );
 
       return entries