In certain contexts, you may want to allow another account to update your posts or post for you. This can be done by creating a Security Key .
Copy import { ItemType } from 'aleph-sdk-ts/dist/messages/message' ;
import { Publish as publishPost } from 'aleph-sdk-ts/dist/messages/post' ;
( async () => {
await publishPost ({
account : account1 ,
postType : 'mytype' ,
content : { 'body' : 'first content' } , //'tags': ['Test'] can be add for filtering
channel : 'TEST'
})
})();
The message result is here
Post by: 0x0BBB06C238bE7D4c5Df7BA56b7ad75a09eea5F56
"content": "body": "first content",
Copy import { ItemType } from 'aleph-sdk-ts/dist/messages/message' ;
import { Publish as publishAggregate } from 'aleph-sdk-ts/dist/messages/aggregate' ;
( async () => {
await publishAggregate ({
account : account1 .account ,
key : 'security' ,
content : { 'authorizations' : [
{
'address' : account2 . account .address ,
'types' : [ 'POST' ] ,
'post_types' : [ 'amend' , 'mytype' ] ,
'chains' : [ 'ETH' ] ,
'channels' : [ 'TEST' ]
}
]} ,
channel : 'security'
})
})();
The message result is here
Post by: 0x0BBB06C238bE7D4c5Df7BA56b7ad75a09eea5F56
Update with the delegated account
Copy import { ItemType } from 'aleph-sdk-ts/dist/messages/message' ;
import { Publish as publishPost } from 'aleph-sdk-ts/dist/messages/post' ;
( async () => {
await publishPost ({
address : account1 . account .address ,
account : account2 .account ,
postType : 'amend' ,
ref : res .item_hash ,
content : { 'body' : 'first content updated' , 'tags' : [ 'Test' ]} ,
channel : 'TEST' ,
})
})();
The message result is here
Post by: 0x187669b0329E4da88e4C8c5aE0FFA97636D25424
Copy import { ItemType } from 'aleph-sdk-ts/dist/messages/message' ;
import { Get as getAggregate } from 'aleph-sdk-ts/dist/messages/aggregate' ;
( async () => {
const postList = await getPost ({
types : 'mytype' ,
hashes : [ res .item_hash] // The hash of the first sended message
})
})();
When fetching the result you can see that th content was correctly updated
"content": {"body":"first content updated","tags":["Test"]}