pocketnetteam / pocketnet.core

Decentralized social network based on the blockchain
https://pocketnet.app
Apache License 2.0
115 stars 28 forks source link

Push notifications #280

Open lostystyg opened 2 years ago

lostystyg commented 2 years ago

RPC request with height as a parameter that represents concrete single block. Node parses block and group interested transactions in short form (#217) by user addresses.

lostystyg commented 2 years ago

Required order of selects for all notifications. Every field except 1,6 and 7 is optional

Multiple addresses str - array of objects with address and account data:

[
  {
    "address" : "TG69Jioc81PiwMAJtRanfZqUmRY4TUG7nt",
    "account": {
      "lang" : "en",
      "name": "brangr0",
      "avatar": "imgur.com/123awd",
      "reputation": 101
    }
]
lostystyg commented 2 years ago

TODO: outdated

Request description

"getnotifications" rpc request

Returns all notifications for all addresses from concrete block height

Params:

Response is a map, where keys are addresses of accounts to be notified and values are vectors of Short Forms

Request example:

{
    "method": "getnotifications",
    "params" : [
        414152
    ]
}

Response example:

{
    "result": {
        "user_notifications": {
            "T9yywwbGexGmQUeALuP1RxU2VKyhV4eC7M": [
                {
                    "hash": "478fe8bfccda50279cf70050a5a785777aef2fb60f2f6d8b48615786d8f61085",
                    "txType": 204,
                    "height": 414152,
                    "blockNum": 1309,
                    "address": "TJAf3NwJ5LzdpXEHjBdempTqRdsaUZmzBG",
                    "account": {
                        "name": "TestName00591798033",
                        "avatar": "https://lumpics.ru/wp-content/uploads/2017/11/Programmyi-dlya-sozdaniya-avatarok.png",
                        "badge": "about",
                        "reputation": 0
                    },
                    "description": "{\"message\":\"Test\",\"url\":\"\",\"images\":[]}",
                    "type": "comment",
                    "relatedContent": {
                        "hash": "152f0b941974548741112fbf03c0acf7711fbb45a79542d64bcaecaefe8e708b",
                        "txType": 200,
                        "height": 413962,
                        "blockNum": 470,
                        "description": "Caption"
                    }
                },
                {
                    "hash": "82a63031e377d2068c84d9be9efa4885af12ccb56ce959d40af8b4439a917040",
                    "txType": 204,
                    "height": 414152,
                    "blockNum": 600,
                    "address": "TAt4exgfZpttYT5Z5BJjgMjRPMPR7ixrWs",
                    "account": {
                        "name": "Test0000100337226228",
                        "avatar": "https://lumpics.ru/wp-content/uploads/2017/11/Programmyi-dlya-sozdaniya-avatarok.png",
                        "badge": "about",
                        "reputation": 0
                    },
                    "description": "{\"message\":\"Test\",\"url\":\"\",\"images\":[]}",
                    "type": "comment",
                    "relatedContent": {
                        "hash": "152f0b941974548741112fbf03c0acf7711fbb45a79542d64bcaecaefe8e708b",
                        "txType": 200,
                        "height": 413962,
                        "blockNum": 470,
                        "description": "Caption"
                    }
                },
            ...
            ],
            "TA35ghGfDoZ9NXQqbtFJQUMaUY6gFjo2HP": [
                {
                    "hash": "151bef260de7ceb30d5965aa7adfec7ead7f70ebec3553a62ba8ae801d5f45aa",
                    "txType": 204,
                    "height": 414152,
                    "blockNum": 1648,
                    "address": "TCcn8RrRd5942c22aQeNpisqgR7qjrjEt2",
                    "account": {
                        "name": "TestName00033929485",
                        "avatar": "https://lumpics.ru/wp-content/uploads/2017/11/Programmyi-dlya-sozdaniya-avatarok.png",
                        "badge": "about",
                        "reputation": 0
                    },
                    "description": "{\"message\":\"Test\",\"url\":\"\",\"images\":[]}",
                    "type": "comment",
                    "relatedContent": {
                        "hash": "088174fd7dd46ecd36f5a106d478901778cfe7d5dd1af3c32f51232003efb8ef",
                        "txType": 200,
                        "height": 413962,
                        "blockNum": 854,
                        "description": "Caption"
                    }
                },
                {
                    "hash": "1926e9b480f2e35b6e8be0611cfb7495593e6f962673840a31795c6fa4bd6a97",
                    "txType": 204,
                    "height": 414152,
                    "blockNum": 1481,
                    "address": "TRF7vpvvbG8GQaBetx8XZd7ygsw3KziGfA",
                    "account": {
                        "name": "Test0000100921921461",
                        "avatar": "https://lumpics.ru/wp-content/uploads/2017/11/Programmyi-dlya-sozdaniya-avatarok.png",
                        "badge": "about",
                        "reputation": 0
                    },
                    "description": "{\"message\":\"Test\",\"url\":\"\",\"images\":[]}",
                    "type": "comment",
                    "relatedContent": {
                        "hash": "088174fd7dd46ecd36f5a106d478901778cfe7d5dd1af3c32f51232003efb8ef",
                        "txType": 200,
                        "height": 413962,
                        "blockNum": 854,
                        "description": "Caption"
                    }
                },
            ...
            ],
            ...
        },
        "pocketnetteam": [
            {
                "hash": "3a2c3b6c9b4d4dd43c0be035a32d04f831124a2a903d356b585219a9bfea017e",
                "txType": 200,
                "height": 677171,
                "blockNum": 2,
                "type": "pocketnetteam",
                "description": "Caption"
            },
            ...
        ]
    },
    "error": null,
    "id": null
}
lostystyg commented 2 years ago

TODO: outdated

Concrete examples of format for all ShortForms types

Pocketnetteam Posts

{
    "hash": "3cef7bdef81f803c13ce58efe603609a43b16f19f0c57f3cbad52c4f84191b25",
    "txType": 202,
    "height": 677211,
    "blockNum": 2,
    "address": "TAqR1ncH95eq9XKSDRR18DtpXqktxh74UU",
    "account": {
        "name": "BASTYON_TEAM",
        "avatar": "https://github.com/pocketnetteam/pocketnet.gui/raw/master/img/logo_color/blue_pad_100.png",
        "badge": "",
        "reputation": 0
    },
    "type": "pocketnetteam"
}

Money

{
    "hash": "51904d1ac4c7570302c1203cd1b09da8aebebf95bad5c73d362ae7f02ecf3f84",
    "txType": 3,
    "height": 617736,
    "blockNum": 1,
    "address": "TUhp7mJFywjjenAKfU9gdpgNJ4vAPWxauU",
    "val": 123,
    "type": "money"
}

Answer

{
    "hash": "7b9d9d22190d0659577c62445b1a970e3c8408f5524525b1c6edbb9e7e2b0c52",
    "txType": 204,
    "height": 416415,
    "blockNum": 2,
    "address": "TG942ppcNEa8uhHLnm78M4nnEdGYetARtW",
    "account": {
        "name": "TestSack",
        "avatar": "https://i.imgur.com/Wh7oHZF.jpg",
        "badge": "",
        "reputation": 0
    },
    "description": "{\"message\":\"%40Redhead_Sorceress1%20%20%0Axzcvxv\",\"url\":\"\",\"images\":[]}",
    "commentParentId": "01bc825e350c34e4f492d4c0a65ff6feae267a3fa947d3b3fbe06ef682a17876",
    "commentAnswerId": "01bc825e350c34e4f492d4c0a65ff6feae267a3fa947d3b3fbe06ef682a17876",
    "type": "answer",
    "relatedContent": {
        "hash": "a17ea38a8896fc3ad01748caa26b52766f787e3d854ca5c06ea142a673bd5a7d",
        "txType": 200,
        "height": 416080,
        "blockNum": 3,
        "address": "TG942ppcNEa8uhHLnm78M4nnEdGYetARtW",
        "account": {
            "name": "TestSack",
            "avatar": "https://i.imgur.com/Wh7oHZF.jpg",
            "badge": "",
            "reputation": 0
        }
    }
}

Private content

{
    "hash": "b98a9e6f141145b1113c2c7b54b3b19fdaa807481a5450995b3986e84d6a2253",
    "txType": 202,
    "height": 729638,
    "blockNum": 2,
    "address": "TSisNge5kisi7cwGRwmUBuZQWZFD8cRoG8",
    "account": {
        "name": "Tester101",
        "avatar": "https://pocketnet.app:8092/i/zGuMmqggqbppqFOnZgosxy.jfif",
        "badge": "?",
        "reputation": 40
    },
    "type": "privatecontent"
}

Boost

{
    "hash": "0e9b186ff44460be21d387af30144d5fbeed797423dd3ea7da6b425d58c04118",
    "txType": 208,
    "height": 967114,
    "blockNum": 2,
    "address": "TQPBvaNUyEWoK9AfY7mUfx3BXZWE2fRXQd",
    "account": {
        "name": "Dev01",
        "avatar": "https://i.imgur.com/R7eWJPn.jpg",
        "badge": "?",
        "reputation": 20
    },
    "val": 50000000,
    "type": "boost",
    "relatedContent": {
        "hash": "08b4ae680a7d7a43dbd4642410a24ae61bbe5a7f633764f575615207f12de9d7",
        "txType": 200,
        "height": 964949,
        "blockNum": 2
    }
}
lostystyg commented 2 years ago

Work on this issue will continue in #337 and will be pulled to #302

lostystyg commented 2 years ago

Some notes for the future improvements. Divide money to default money transfers and Lottery/Coinstake incomings:

lostystyg commented 2 years ago

The info in the issue is pretty outdated... Need to actualize all descriptions before closing