p2p-database-gun.ts 834 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Injectable } from "@angular/core";
  2. import Gun from "gun";
  3. /*
  4. Generated class for the P2pDatabaseGunProvider provider.
  5. See https://angular.io/guide/dependency-injection for more info on providers
  6. and Angular DI.
  7. */
  8. @Injectable()
  9. export class P2pDatabaseGunProvider {
  10. private gun;
  11. constructor() {
  12. this.gun = Gun();
  13. }
  14. public storeLastTweetHashForUser(userid, hash): void {
  15. this.gun.get(userid).put({ lastTweet: hash });
  16. }
  17. public async getLastTweetFromUser(userid) {
  18. return new Promise(resolve =>
  19. this.gun
  20. .get(userid)
  21. .get("lastTweet")
  22. .once(resolve)
  23. );
  24. }
  25. public fetchPrivateTweetHashsForUserInInterval(
  26. userId,
  27. intervalStart,
  28. intervalEnd
  29. ): string[] {
  30. // return ["QmU37grV5ZoK4d5d2Cooaf429LuD31WyFbAMw2f1DHtvaS"];
  31. return [];
  32. }
  33. }