mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Rename followed to following (#170)
* Rename followed field to following in profile * Rename shared field to sharing in profile * Revert changes to icons.js * Rename following squeaks to followed squeaks * Fix frontend for renamed get followed request
This commit is contained in:
parent
bb97f8a515
commit
cdca52b7e2
11 changed files with 78 additions and 79 deletions
|
|
@ -19,7 +19,7 @@ import Widget from "../../components/Widget";
|
|||
|
||||
import {
|
||||
GetSqueakProfileRequest,
|
||||
SetSqueakProfileFollowedRequest,
|
||||
SetSqueakProfileFollowingRequest,
|
||||
} from "../../proto/squeak_admin_pb"
|
||||
import { SqueakAdminClient } from "../../proto/squeak_admin_grpc_web_pb"
|
||||
|
||||
|
|
@ -45,13 +45,13 @@ export default function ProfilePage() {
|
|||
setSqueakProfile(response.getSqueakProfile())
|
||||
});
|
||||
};
|
||||
const setFollowed = (id, followed) => {
|
||||
console.log("called setFollowed with profileId: " + id + ", followed: " + followed);
|
||||
var setSqueakProfileFollowedRequest = new SetSqueakProfileFollowedRequest()
|
||||
setSqueakProfileFollowedRequest.setProfileId(id);
|
||||
setSqueakProfileFollowedRequest.setFollowed(followed);
|
||||
console.log(setSqueakProfileFollowedRequest);
|
||||
client.setSqueakProfileFollowed(setSqueakProfileFollowedRequest, {}, (err, response) => {
|
||||
const setFollowing = (id, following) => {
|
||||
console.log("called setFollowing with profileId: " + id + ", following: " + following);
|
||||
var setSqueakProfileFollowingRequest = new SetSqueakProfileFollowingRequest()
|
||||
setSqueakProfileFollowingRequest.setProfileId(id);
|
||||
setSqueakProfileFollowingRequest.setFollowing(following);
|
||||
console.log(setSqueakProfileFollowingRequest);
|
||||
client.setSqueakProfileFollowing(setSqueakProfileFollowingRequest, {}, (err, response) => {
|
||||
console.log(response);
|
||||
getSqueakProfile(id);
|
||||
});
|
||||
|
|
@ -62,10 +62,10 @@ export default function ProfilePage() {
|
|||
getSqueakProfile(id)
|
||||
},[id]);
|
||||
|
||||
const handleSettingsFollowedChange = (event) => {
|
||||
const handleSettingsFollowingChange = (event) => {
|
||||
console.log("Settings changed for profile id: " + id);
|
||||
console.log("Followed changed to: " + event.target.checked);
|
||||
setFollowed(id, event.target.checked);
|
||||
console.log("Following changed to: " + event.target.checked);
|
||||
setFollowing(id, event.target.checked);
|
||||
};
|
||||
|
||||
const handleSettingsChange = (event) => {
|
||||
|
|
@ -98,12 +98,12 @@ export default function ProfilePage() {
|
|||
<FormLabel component="legend">Profile settings</FormLabel>
|
||||
<FormGroup>
|
||||
<FormControlLabel
|
||||
control={<Switch checked={squeakProfile.getFollowed()} onChange={handleSettingsFollowedChange} />}
|
||||
label="Followed"
|
||||
control={<Switch checked={squeakProfile.getFollowing()} onChange={handleSettingsFollowingChange} />}
|
||||
label="Following"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={<Switch checked={squeakProfile.getShared()} onChange={handleSettingsChange} />}
|
||||
label="Shared"
|
||||
control={<Switch checked={squeakProfile.getSharing()} onChange={handleSettingsChange} />}
|
||||
label="Sharing"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={<Switch checked={squeakProfile.getWhitelisted()} onChange={handleSettingsChange} />}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import mock from "../dashboard/mock";
|
|||
import {GetInfoRequest} from "../../proto/lnd_pb"
|
||||
import {
|
||||
HelloRequest,
|
||||
GetFollowedSqueakDisplaysRequest,
|
||||
GetSigningProfilesRequest,
|
||||
GetContactProfilesRequest,
|
||||
} from "../../proto/squeak_admin_pb"
|
||||
|
|
@ -261,11 +260,11 @@ export default function Profiles() {
|
|||
[
|
||||
p.getProfileName(),
|
||||
p.getAddress(),
|
||||
p.getFollowed().toString(),
|
||||
p.getShared().toString(),
|
||||
p.getFollowing().toString(),
|
||||
p.getSharing().toString(),
|
||||
]
|
||||
)}
|
||||
columns={["Name", "Address", "Followed", "Shared"]}
|
||||
columns={["Name", "Address", "Following", "Sharing"]}
|
||||
options={{
|
||||
filter: false,
|
||||
print: false,
|
||||
|
|
@ -294,11 +293,11 @@ export default function Profiles() {
|
|||
[
|
||||
p.getProfileName(),
|
||||
p.getAddress(),
|
||||
p.getFollowed().toString(),
|
||||
p.getShared().toString(),
|
||||
p.getFollowing().toString(),
|
||||
p.getSharing().toString(),
|
||||
]
|
||||
)}
|
||||
columns={["Name", "Address", "Followed", "Shared"]}
|
||||
columns={["Name", "Address", "Following", "Sharing"]}
|
||||
options={{
|
||||
filter: false,
|
||||
print: false,
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ export default function TimelinePage() {
|
|||
|
||||
const getSqueaks = () => {
|
||||
console.log("called getSqueaks");
|
||||
var getSqueaksRequest = new GetFollowedSqueakDisplaysRequest()
|
||||
client.getFollowedSqueakDisplays(getSqueaksRequest, {}, (err, response) => {
|
||||
var getFollowedSqueakDisplaysRequest = new GetFollowedSqueakDisplaysRequest()
|
||||
client.getFollowedSqueakDisplays(getFollowedSqueakDisplaysRequest, {}, (err, response) => {
|
||||
console.log(response);
|
||||
setSqueaks(response.getSqueakDisplayEntriesList())
|
||||
});
|
||||
|
|
|
|||
4
init.sql
4
init.sql
|
|
@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS profile (
|
|||
profile_name VARCHAR(64) NOT NULL,
|
||||
private_key bytea,
|
||||
address VARCHAR(35) UNIQUE NOT NULL, -- Maximum length of a bitcoin address is 35.
|
||||
shared BOOLEAN NOT NULL,
|
||||
followed BOOLEAN NOT NULL,
|
||||
sharing BOOLEAN NOT NULL,
|
||||
following BOOLEAN NOT NULL,
|
||||
whitelisted BOOLEAN NOT NULL
|
||||
);
|
||||
|
|
|
|||
|
|
@ -335,18 +335,18 @@ def test_set_profile_whitelisted(server_stub, admin_stub, contact_profile_id):
|
|||
)
|
||||
assert get_squeak_profile_response.squeak_profile.whitelisted == True
|
||||
|
||||
def test_set_profile_followed(server_stub, admin_stub, contact_profile_id):
|
||||
def test_set_profile_following(server_stub, admin_stub, contact_profile_id):
|
||||
# Get the existing profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(profile_id=contact_profile_id,)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.followed == False
|
||||
assert get_squeak_profile_response.squeak_profile.following == False
|
||||
|
||||
# Set the profile to be followed
|
||||
admin_stub.SetSqueakProfileFollowed(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowedRequest(
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
followed=True,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -354,14 +354,14 @@ def test_set_profile_followed(server_stub, admin_stub, contact_profile_id):
|
|||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(profile_id=contact_profile_id,)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.followed == True
|
||||
assert get_squeak_profile_response.squeak_profile.following == True
|
||||
|
||||
def test_get_followed_squeaks(server_stub, admin_stub, saved_squeak_hash, signing_profile_id):
|
||||
# Set the profile to be followed
|
||||
admin_stub.SetSqueakProfileFollowed(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowedRequest(
|
||||
def test_get_following_squeaks(server_stub, admin_stub, saved_squeak_hash, signing_profile_id):
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=signing_profile_id,
|
||||
followed=True,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ service SqueakAdmin {
|
|||
*/
|
||||
rpc SetSqueakProfileWhitelisted (SetSqueakProfileWhitelistedRequest) returns (SetSqueakProfileWhitelistedReply) {}
|
||||
|
||||
/** sqkadmin: `setsqueakprofilefollowed`
|
||||
/** sqkadmin: `setsqueakprofilefollowing`
|
||||
*/
|
||||
rpc SetSqueakProfileFollowed (SetSqueakProfileFollowedRequest) returns (SetSqueakProfileFollowedReply) {}
|
||||
rpc SetSqueakProfileFollowing (SetSqueakProfileFollowingRequest) returns (SetSqueakProfileFollowingReply) {}
|
||||
|
||||
/** sqkadmin: `makesqueak`
|
||||
*/
|
||||
|
|
@ -154,15 +154,15 @@ message SetSqueakProfileWhitelistedRequest {
|
|||
message SetSqueakProfileWhitelistedReply {
|
||||
}
|
||||
|
||||
message SetSqueakProfileFollowedRequest {
|
||||
message SetSqueakProfileFollowingRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// Followed
|
||||
bool followed = 2;
|
||||
/// Following
|
||||
bool following = 2;
|
||||
}
|
||||
|
||||
message SetSqueakProfileFollowedReply {
|
||||
message SetSqueakProfileFollowingReply {
|
||||
}
|
||||
|
||||
message SqueakProfile {
|
||||
|
|
@ -178,11 +178,11 @@ message SqueakProfile {
|
|||
/// The address
|
||||
string address = 4;
|
||||
|
||||
/// Shared
|
||||
bool shared = 5;
|
||||
/// Sharing
|
||||
bool sharing = 5;
|
||||
|
||||
/// Followed
|
||||
bool followed = 6;
|
||||
/// Following
|
||||
bool following = 6;
|
||||
|
||||
/// Whitelisted
|
||||
bool whitelisted = 7;
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ class SqueakAdminServerHandler(object):
|
|||
))
|
||||
self.squeak_node.set_squeak_profile_whitelisted(profile_id, whitelisted)
|
||||
|
||||
def handle_set_squeak_profile_followed(self, profile_id, followed):
|
||||
logger.info("Handle set squeak profile followed with profile id: {}, followed: {}".format(
|
||||
def handle_set_squeak_profile_following(self, profile_id, following):
|
||||
logger.info("Handle set squeak profile following with profile id: {}, following: {}".format(
|
||||
profile_id,
|
||||
followed,
|
||||
following,
|
||||
))
|
||||
self.squeak_node.set_squeak_profile_followed(profile_id, followed)
|
||||
self.squeak_node.set_squeak_profile_following(profile_id, following)
|
||||
|
||||
def handle_make_squeak(self, profile_id, content_str, replyto_hash):
|
||||
logger.info("Handle make squeak profile with id: {}".format(profile_id))
|
||||
|
|
@ -96,7 +96,7 @@ class SqueakAdminServerHandler(object):
|
|||
logger.info("Handle get followed squeak display entries.")
|
||||
squeak_entries_with_profile = self.squeak_node.get_followed_squeak_entries_with_profile()
|
||||
logger.info(
|
||||
"Got number of squeak entries: {}".format(
|
||||
"Got number of followed squeak entries: {}".format(
|
||||
len(squeak_entries_with_profile)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
self.handler.handle_set_squeak_profile_whitelisted(profile_id, whitelisted)
|
||||
return squeak_admin_pb2.SetSqueakProfileWhitelistedReply()
|
||||
|
||||
def SetSqueakProfileFollowed(self, request, context):
|
||||
def SetSqueakProfileFollowing(self, request, context):
|
||||
profile_id = request.profile_id
|
||||
followed = request.followed
|
||||
self.handler.handle_set_squeak_profile_followed(profile_id, followed)
|
||||
return squeak_admin_pb2.SetSqueakProfileFollowedReply()
|
||||
following = request.following
|
||||
self.handler.handle_set_squeak_profile_following(profile_id, following)
|
||||
return squeak_admin_pb2.SetSqueakProfileFollowingReply()
|
||||
|
||||
def MakeSqueak(self, request, context):
|
||||
profile_id = request.profile_id
|
||||
|
|
@ -140,7 +140,7 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
for entry in
|
||||
squeak_entries_with_profile
|
||||
]
|
||||
return squeak_admin_pb2.GetFollowedSqueakDisplaysReply(
|
||||
return squeak_admin_pb2.GetAddressSqueakDisplaysReply(
|
||||
squeak_display_entries=squeak_display_msgs
|
||||
)
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
for entry in
|
||||
squeak_entries_with_profile
|
||||
]
|
||||
return squeak_admin_pb2.GetFollowedSqueakDisplaysReply(
|
||||
return squeak_admin_pb2.GetAncestorSqueakDisplaysReply(
|
||||
squeak_display_entries=squeak_display_msgs
|
||||
)
|
||||
|
||||
|
|
@ -194,8 +194,8 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
profile_name=squeak_profile.profile_name,
|
||||
has_private_key=has_private_key,
|
||||
address=squeak_profile.address,
|
||||
shared=squeak_profile.shared,
|
||||
followed=squeak_profile.followed,
|
||||
sharing=squeak_profile.sharing,
|
||||
following=squeak_profile.following,
|
||||
whitelisted=squeak_profile.whitelisted,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ class SqueakNode:
|
|||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
shared=False,
|
||||
followed=False,
|
||||
sharing=False,
|
||||
following=False,
|
||||
whitelisted=False,
|
||||
)
|
||||
return self.postgres_db.insert_profile(squeak_profile)
|
||||
|
|
@ -148,8 +148,8 @@ class SqueakNode:
|
|||
profile_name=profile_name,
|
||||
private_key=None,
|
||||
address=squeak_address,
|
||||
shared=False,
|
||||
followed=False,
|
||||
sharing=False,
|
||||
following=False,
|
||||
whitelisted=False,
|
||||
)
|
||||
return self.postgres_db.insert_profile(squeak_profile)
|
||||
|
|
@ -170,8 +170,8 @@ class SqueakNode:
|
|||
self.postgres_db.set_profile_whitelisted(profile_id, whitelisted)
|
||||
self.squeak_whitelist.refresh()
|
||||
|
||||
def set_squeak_profile_followed(self, profile_id, followed):
|
||||
self.postgres_db.set_profile_followed(profile_id, followed)
|
||||
def set_squeak_profile_following(self, profile_id, following):
|
||||
self.postgres_db.set_profile_following(profile_id, following)
|
||||
|
||||
def make_squeak(self, profile_id, content_str, replyto_hash):
|
||||
squeak_profile = self.postgres_db.get_profile(profile_id)
|
||||
|
|
|
|||
|
|
@ -110,13 +110,13 @@ class PostgresDb:
|
|||
return self._parse_squeak_entry_with_profile(row)
|
||||
|
||||
def get_followed_squeak_entries_with_profile(self):
|
||||
""" Get a squeak. """
|
||||
""" Get all followed squeaks. """
|
||||
sql = """
|
||||
SELECT * FROM squeak
|
||||
JOIN profile
|
||||
ON squeak.author_address=profile.address
|
||||
WHERE squeak.block_header IS NOT NULL
|
||||
AND profile.followed
|
||||
AND profile.following
|
||||
ORDER BY n_block_height DESC, n_time DESC;
|
||||
"""
|
||||
with self.get_cursor() as curs:
|
||||
|
|
@ -189,7 +189,7 @@ class PostgresDb:
|
|||
def insert_profile(self, squeak_profile):
|
||||
""" Insert a new squeak profile. """
|
||||
sql = """
|
||||
INSERT INTO profile(profile_name, private_key, address, shared, followed, whitelisted)
|
||||
INSERT INTO profile(profile_name, private_key, address, sharing, following, whitelisted)
|
||||
VALUES(%s, %s, %s, %s, %s, %s)
|
||||
RETURNING profile_id;
|
||||
"""
|
||||
|
|
@ -201,8 +201,8 @@ class PostgresDb:
|
|||
squeak_profile.profile_name,
|
||||
squeak_profile.private_key,
|
||||
squeak_profile.address,
|
||||
squeak_profile.shared,
|
||||
squeak_profile.followed,
|
||||
squeak_profile.sharing,
|
||||
squeak_profile.following,
|
||||
squeak_profile.whitelisted,
|
||||
),
|
||||
)
|
||||
|
|
@ -277,15 +277,15 @@ class PostgresDb:
|
|||
with self.get_cursor() as curs:
|
||||
curs.execute(sql, (whitelisted, profile_id,))
|
||||
|
||||
def set_profile_followed(self, profile_id, followed):
|
||||
""" Set a profile is followed. """
|
||||
def set_profile_following(self, profile_id, following):
|
||||
""" Set a profile is following. """
|
||||
sql = """
|
||||
UPDATE profile
|
||||
SET followed=%s
|
||||
SET following=%s
|
||||
WHERE profile_id=%s;
|
||||
"""
|
||||
with self.get_cursor() as curs:
|
||||
curs.execute(sql, (followed, profile_id,))
|
||||
curs.execute(sql, (following, profile_id,))
|
||||
|
||||
def get_unverified_block_squeaks(self):
|
||||
""" Get all squeaks without block header. """
|
||||
|
|
@ -356,8 +356,8 @@ class PostgresDb:
|
|||
profile_name=row["profile_name"],
|
||||
private_key=private_key,
|
||||
address=row["address"],
|
||||
shared=row["shared"],
|
||||
followed=row["followed"],
|
||||
sharing=row["sharing"],
|
||||
following=row["following"],
|
||||
whitelisted=row["whitelisted"],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ from collections import namedtuple
|
|||
|
||||
SqueakProfile = namedtuple(
|
||||
"SqueakProfile",
|
||||
"profile_id, profile_name, private_key, address, shared, followed, whitelisted",
|
||||
"profile_id, profile_name, private_key, address, sharing, following, whitelisted",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue