|
@@ -11,7 +11,7 @@ import "gun/lib/then";
|
|
|
@Injectable()
|
|
|
export class P2pDatabaseGunProvider {
|
|
|
private gun;
|
|
|
- osnPrefix: string = "hybridOSN-";
|
|
|
+ osnPrefix: string = "hybridOSN-beta001";
|
|
|
|
|
|
constructor() {
|
|
|
this.gun = Gun();
|
|
@@ -22,7 +22,7 @@ export class P2pDatabaseGunProvider {
|
|
|
.get(timestamp)
|
|
|
.put({ hash: hash, created_at: timestamp });
|
|
|
this.gun
|
|
|
- .get(this.osnPrefix + userId)
|
|
|
+ .get(this.osnPrefix + "-" + userId)
|
|
|
.get("tweets")
|
|
|
.set(tweet);
|
|
|
}
|
|
@@ -42,7 +42,7 @@ export class P2pDatabaseGunProvider {
|
|
|
intervalEnd
|
|
|
): Promise<string[]> {
|
|
|
const gunIds = await this.gun
|
|
|
- .get(this.osnPrefix + userId)
|
|
|
+ .get(this.osnPrefix + "-" + userId)
|
|
|
.get("tweets")
|
|
|
.then();
|
|
|
|
|
@@ -64,4 +64,26 @@ export class P2pDatabaseGunProvider {
|
|
|
return [];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Hashtags are stored without reference to the users to provide these information on an extra dashboard to twitter
|
|
|
+ * @param hashtagEntity extracted hashtags
|
|
|
+ */
|
|
|
+ public publishHashtags(hashtagEntity): void {
|
|
|
+ const timestamp = Date.now();
|
|
|
+ const hashtagsCommaSeparated = hashtagEntity
|
|
|
+ .map(el => el.hashtag)
|
|
|
+ .sort()
|
|
|
+ .join("|");
|
|
|
+
|
|
|
+ const hashtags = this.gun.get(timestamp).put({
|
|
|
+ hashtags: hashtagsCommaSeparated,
|
|
|
+ created_at: timestamp
|
|
|
+ });
|
|
|
+
|
|
|
+ this.gun
|
|
|
+ .get(this.osnPrefix)
|
|
|
+ .get("hashtags")
|
|
|
+ .set(hashtags);
|
|
|
+ }
|
|
|
}
|