Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: Update devapps sdk #1259

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion config/Bastyon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"turl" : "test.pocketnet.app",
"name" : "Bastyon",
"fullname" : "Bastyon",
"developapps" : [],
"developapps" : [
{
"id" : "barteron.pocketnet.app",
"version": "1.0.0",
"scope" : "test.barter.pocketnet.app",
"cantdelete" : true,
"name" : "Barteron",
"grantedPermissions" : ["account", "chat"]
}
],
"protocol" : "bastyon",
"support" : "[email protected]",
"lname" : "Dvm Analytics LLC",
Expand Down
196 changes: 194 additions & 2 deletions js/kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,22 @@ Comment = function(txid){
v : []
}

self.info = {
set : function(_v){

if(!_v){
this.v = ''
}
else

this.v = _v

if (self.on.change)
self.on.change('info', this.v)
},
v : ''
}

self.donate = {
set : function(donate){

Expand Down Expand Up @@ -517,6 +533,7 @@ Comment = function(txid){
images : _.map(self.images.v, function(i){
return (i)
}),
info : (self.info.v || '')

}))

Expand All @@ -540,7 +557,8 @@ Comment = function(txid){
r.msgparsed = {
message : self.message.v,
url : self.url.v,
images : self.images.v
images : self.images.v,
info : self.info.v
}
}
else{
Expand All @@ -550,6 +568,7 @@ Comment = function(txid){
images : _.map(self.images.v, function(i){
return (i)
}),
info : self.info.v
})
}

Expand Down Expand Up @@ -589,12 +608,15 @@ Comment = function(txid){
self.images.set(_.map(v.msgparsed.images, function(i){
return decodeURIComponent(i)
}))
self.info.set(v.msgparsed.info)
}

if (v.msgparsed){
self.url.set(v.msgparsed.url)
self.message.set(v.msgparsed.message)
self.images.set(v.msgparsed.images)
self.info.set(v.msgparsed.info)

}

if (v.donate){
Expand Down Expand Up @@ -2162,6 +2184,170 @@ Transaction = function(){

}

/* BARTERON */

brtAccount = function(){
var self = this;

self.address = '';
self.tags = [];
self.geohash = '';
self.static = false;
self.radius = 0;

self.validation = function(){

}

self.serialize = function(){
return self.address +
JSON.stringify({
a: self.tags,
g: self.geohash,
s: self.static,
r: self.radius
});
}

self.export = function(alias){
if(alias){
return {
address: self.address,
tags: self.tags,
geohash: self.geohash,
static: self.static,
radius: self.radius
};
}

return {
s1: self.address,
p: {
s4: JSON.stringify({
a: self.tags,
g: self.geohash,
s: self.static,
r: self.radius
})
}
};
}

self.import = function(d){
self.address = d.address || app.user.address.value;
self.tags = d.tags;
self.geohash = d.geohash;
self.static = d.static;
self.radius = d.radius;
}

self.type = 'brtaccount';

return self;
}

brtOffer = function(){
var self = this;

self.hash = null;
self.address = '';
self.language = '';
self.caption = '';
self.description = '';
self.tag = '';
self.tags = [];
self.condition = [];
self.images = [];
self.geohash = '';
self.price = 0;

self.validation = function(){
if(!self.address) return 'address';
if(!self.language) return 'language';
if(!self.caption) return 'caption';
if(!self.description) return 'description';
if(!self.tag) return 'tag';
if(!self.tags) return 'tags';
if(!self.condition) return 'condition';
if(!self.images) return 'images';
if(!self.geohash) return 'geohash';
if(!(self.price > -1)) return 'price';
}

self.serialize = function(){
return self.address +
(self.hash ?? '') +
self.language +
self.caption +
self.description +
JSON.stringify({
t: self.tag,
a: self.tags,
c: self.condition
}) +
JSON.stringify(self.images) +
self.geohash +
self.price;
}

self.export = function(alias){
if(alias){
return {
address: self.address,
hash: self.hash || null,
language: self.language,
caption: self.caption,
description: self.description,
tag: self.tag,
tags: self.tags,
condition: self.condition,
images: self.images,
geohash: self.geohash,
price: self.price
};
}

return {
s1: self.address,
...(self.hash && { s2: self.hash }),
p: {
s1: self.language,
s2: self.caption,
s3: self.description,
s4: JSON.stringify({
t: self.tag,
a: self.tags,
c: self.condition,
}),
s5: JSON.stringify(self.images),
s6: self.geohash,
i1: self.price
}
};
}

self.import = function(d){
self.address = d.address || app.user.address.value;
self.hash = d.hash || null;
self.language = d.language;
self.caption = d.caption;
self.description = d.description;
self.tag = d.tag;
self.tags = d.tags;
self.condition = d.condition,
self.images = d.images;
self.geohash = d.geohash;
self.price = d.price;
}

self.type = 'brtoffer';

return self;
}


/* ---- */


pUserInfo = function(){

Expand Down Expand Up @@ -2982,6 +3168,7 @@ pComment = function(){
self.url = ''
self.message = ''
self.images = [];
self.info = ''

self.postid = '';
self.id = '';
Expand Down Expand Up @@ -3020,6 +3207,7 @@ pComment = function(){
self.url = v.msgparsed.url;
self.message = v.msgparsed.message
self.images = v.msgparsed.images
self.info = v.msgparsed.info || ''
}

self.postid = v.postid;
Expand Down Expand Up @@ -3084,6 +3272,7 @@ pComment = function(){
message : self.message,
url : self.url,
images : self.images,
info : self.info
},
scoreDown : self.scoreDown,
scoreUp : self.scoreUp,
Expand Down Expand Up @@ -3654,7 +3843,10 @@ kits = {
accDel : DeleteAccount,
transaction : Transaction,
contentDelete : Remove,
accSet : Settings
accSet : Settings,
brtoffer : brtOffer,
brtaccount : brtAccount

},

ini : {
Expand Down
14 changes: 13 additions & 1 deletion js/lib/apps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,24 @@ var BastyonApps = function(app){
permissions : ['account'],
authorization : true,
action : function({data, application}){
var comment = new brtComment();
var comment = new Comment();

comment.import(data);

return makeAction(comment, application)
}
},

vote : {
permissions : ['account'],
authorization : true,
action : function({data, application}){
var vote = new UpvoteShare();

vote.import(data);

return makeAction(vote, application)
}
}
}

Expand Down
Loading