File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package indexer
2+
3+ import (
4+ "encoding/json"
5+
6+ "github.com/AudiusProject/audiusd/pkg/core/gen/core_proto"
7+ "github.com/jackc/pgx/v5"
8+ )
9+
10+ func (ci * CoreIndexer ) createComment (txInfo TxInfo , em * core_proto.ManageEntityLegacy ) error {
11+ var metadata GenericMetadata
12+ if err := json .Unmarshal ([]byte (em .Metadata ), & metadata ); err != nil {
13+ return err
14+ }
15+
16+ args := pgx.NamedArgs {
17+ "comment_id" : metadata .Data ["comment_id" ],
18+ "user_id" : em .UserId ,
19+ "text" : metadata .Data ["body" ],
20+ "entity_type" : "track" ,
21+ "entity_id" : metadata .Data ["track_id" ],
22+
23+ "txhash" : txInfo .txhash ,
24+ "blockhash" : txInfo .blockhash ,
25+ "blocknumber" : txInfo .blocknumber ,
26+ }
27+
28+ return ci .doInsert ("comments" , args )
29+ }
Original file line number Diff line number Diff line change @@ -82,6 +82,9 @@ func (ci *CoreIndexer) handleTx(signedTx *core_proto.SignedTransaction) error {
8282 case "UpdatePlaylist" :
8383 err = ci .updatePlaylist (txInfo , em )
8484
85+ case "CreateComment" :
86+ err = ci .createComment (txInfo , em )
87+
8588 case "FollowUser" :
8689 err = ci .followUser (txInfo , em )
8790 case "UnfollowUser" :
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ func TestMain(m *testing.M) {
5252 alter table saves drop constraint saves_blocknumber_fkey;
5353 alter table notification_seen drop constraint notification_seen_blocknumber_fkey;
5454 alter table track_downloads drop constraint track_downloads_blocknumber_fkey;
55+ alter table comments drop constraint comments_blocknumber_fkey;
5556 ` )
5657 checkErr (err )
5758
You can’t perform that action at this time.
0 commit comments