mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Revert back the revert to use address for profile primary key
This commit is contained in:
parent
5678fddf18
commit
ebd61823aa
36 changed files with 284 additions and 426 deletions
|
|
@ -62,15 +62,17 @@ export default function ConfigureProfileDialog({
|
|||
};
|
||||
|
||||
const handleSettingsFollowingChange = (event) => {
|
||||
console.log("Following changed for profile id: " + squeakProfile.getProfileId());
|
||||
const profileAddress = squeakProfile.getAddress();
|
||||
console.log("Following changed for profile with address: " + profileAddress);
|
||||
console.log("Following changed to: " + event.target.checked);
|
||||
setFollowing(squeakProfile.getProfileId(), event.target.checked);
|
||||
setFollowing(profileAddress, event.target.checked);
|
||||
};
|
||||
|
||||
const handleSettingsSharingChange = (event) => {
|
||||
console.log("Sharing changed for profile id: " + squeakProfile.getProfileId());
|
||||
const profileAddress = squeakProfile.getAddress();
|
||||
console.log("Sharing changed for profile with address: " + profileAddress);
|
||||
console.log("Sharing changed to: " + event.target.checked);
|
||||
setSharing(squeakProfile.getProfileId(), event.target.checked);
|
||||
setSharing(profileAddress, event.target.checked);
|
||||
};
|
||||
|
||||
function MakeCancelButton() {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default function CreateContactProfileDialog({
|
|||
};
|
||||
|
||||
const handleResponse = (response) => {
|
||||
goToProfilePage(history, response.getProfileId());
|
||||
goToProfilePage(history, response.getAddress());
|
||||
};
|
||||
|
||||
const handleErr = (err) => {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export default function CreateSigningProfileDialog({
|
|||
};
|
||||
|
||||
const handleResponse = (response) => {
|
||||
goToProfilePage(history, response.getProfileId());
|
||||
goToProfilePage(history, response.getAddress());
|
||||
};
|
||||
|
||||
const handleErr = (err) => {
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ export default function DeleteProfileDialog({
|
|||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
console.log( 'profile:', profile);
|
||||
var profileId = profile.getProfileId();
|
||||
console.log( 'profileId:', profileId);
|
||||
deleteProfile(profileId);
|
||||
var squeakAddress = profile.getAddress();
|
||||
console.log( 'squeakAddress:', squeakAddress);
|
||||
deleteProfile(squeakAddress);
|
||||
handleClose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ export default function ExportPrivateKeyDialog({
|
|||
};
|
||||
|
||||
const getPrivateKey = () => {
|
||||
var profileId = profile.getProfileId();
|
||||
getSqueakProfilePrivateKey(profileId, (response) => {
|
||||
var profileAddress = profile.getAddress();
|
||||
getSqueakProfilePrivateKey(profileAddress, (response) => {
|
||||
setPrivateKey(response.getPrivateKey());
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ export default function ImportSigningProfileDialog({
|
|||
};
|
||||
|
||||
const handleResponse = (response) => {
|
||||
goToProfilePage(history, response.getProfileId());
|
||||
const profileAddress = response.getAddress();
|
||||
goToProfilePage(history, profileAddress);
|
||||
};
|
||||
|
||||
const handleErr = (err) => {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ export default function MakeSqueakDialog({
|
|||
onChange={handleChange}
|
||||
>
|
||||
{signingProfiles.map(p =>
|
||||
<MenuItem key={p.getProfileId()} value={p.getProfileId()}>{p.getProfileName()}</MenuItem>
|
||||
<MenuItem key={p.getAddress()} value={p.getAddress()}>{p.getProfileName()}</MenuItem>
|
||||
)}
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export default function UpdateProfileImageDialog({
|
|||
|
||||
const updateProfileImage = (imageStr) => {
|
||||
setSqueakProfileImageRequest(
|
||||
squeakProfile.getProfileId(),
|
||||
squeakProfile.getAddress(),
|
||||
imageStr,
|
||||
handleResponse,
|
||||
handleErr,
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ export const goToChannelPage = (history, txId, outputIndex) => {
|
|||
history.push("/app/channel/" + txId + "/" + outputIndex);
|
||||
};
|
||||
|
||||
export const goToProfilePage = (history, profileId) => {
|
||||
history.push("/app/profile/" + profileId);
|
||||
export const goToProfilePage = (history, squeakAddress) => {
|
||||
history.push("/app/profile/" + squeakAddress);
|
||||
};
|
||||
|
||||
export const goToWalletPage = (history) => {
|
||||
|
|
|
|||
|
|
@ -230,21 +230,14 @@ export default function Profiles() {
|
|||
title={title}
|
||||
data={profiles.map(p =>
|
||||
[
|
||||
p.getProfileId(),
|
||||
p.getProfileName(),
|
||||
p.getAddress(),
|
||||
p.getProfileName(),
|
||||
p.getFollowing().toString(),
|
||||
p.getSharing().toString(),
|
||||
]
|
||||
)}
|
||||
columns={[
|
||||
{
|
||||
name: "Id",
|
||||
options: {
|
||||
display: false,
|
||||
}
|
||||
},
|
||||
"Name", "Address", "Following", "Sharing"
|
||||
"Address", "Name", "Following", "Sharing"
|
||||
]}
|
||||
options={{
|
||||
filter: false,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';
|
|||
import FaceIcon from '@material-ui/icons/Face';
|
||||
|
||||
import {
|
||||
getSqueakProfileByAddressRequest,
|
||||
getSqueakProfileRequest,
|
||||
getAddressSqueakDisplaysRequest,
|
||||
getNetworkRequest,
|
||||
} from "../../squeakclient/requests"
|
||||
|
|
@ -48,7 +48,7 @@ export default function SqueakAddressPage() {
|
|||
const [network, setNetwork] = useState("");
|
||||
|
||||
const getSqueakProfile = (address) => {
|
||||
getSqueakProfileByAddressRequest(address, setSqueakProfile);
|
||||
getSqueakProfileRequest(address, setSqueakProfile);
|
||||
};
|
||||
const getSqueaks = (address) => {
|
||||
getAddressSqueakDisplaysRequest(address, setSqueaks);
|
||||
|
|
@ -91,7 +91,7 @@ export default function SqueakAddressPage() {
|
|||
<div className={classes.root}>
|
||||
Profile:
|
||||
<Button variant="contained" onClick={() => {
|
||||
goToProfilePage(history, squeakProfile.getProfileId());
|
||||
goToProfilePage(history, squeakProfile.getAddress());
|
||||
}}>{squeakProfile.getProfileName()}</Button>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import {
|
|||
GetSqueakDisplayRequest,
|
||||
GetAncestorSqueakDisplaysRequest,
|
||||
GetReplySqueakDisplaysRequest,
|
||||
GetSqueakProfileByAddressRequest,
|
||||
GetAddressSqueakDisplaysRequest,
|
||||
CreateContactProfileRequest,
|
||||
CreateSigningProfileRequest,
|
||||
|
|
@ -69,7 +68,6 @@ import {
|
|||
GetSqueakDisplayReply,
|
||||
GetAncestorSqueakDisplaysReply,
|
||||
GetReplySqueakDisplaysReply,
|
||||
GetSqueakProfileByAddressReply,
|
||||
GetAddressSqueakDisplaysReply,
|
||||
CreateContactProfileReply,
|
||||
CreateSigningProfileReply,
|
||||
|
|
@ -238,9 +236,9 @@ export function lndPendingChannelsRequest(handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getSqueakProfileRequest(id, handleResponse) {
|
||||
export function getSqueakProfileRequest(address, handleResponse) {
|
||||
var request = new GetSqueakProfileRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(address);
|
||||
makeRequest(
|
||||
'getsqueakprofile',
|
||||
request,
|
||||
|
|
@ -251,9 +249,9 @@ export function getSqueakProfileRequest(id, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function setSqueakProfileFollowingRequest(id, following, handleResponse) {
|
||||
export function setSqueakProfileFollowingRequest(squeakAddress, following, handleResponse) {
|
||||
var request = new SetSqueakProfileFollowingRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(squeakAddress);
|
||||
request.setFollowing(following);
|
||||
makeRequest(
|
||||
'setsqueakprofilefollowing',
|
||||
|
|
@ -263,9 +261,9 @@ export function setSqueakProfileFollowingRequest(id, following, handleResponse)
|
|||
);
|
||||
}
|
||||
|
||||
export function setSqueakProfileSharingRequest(id, sharing, handleResponse) {
|
||||
export function setSqueakProfileSharingRequest(squeakAddress, sharing, handleResponse) {
|
||||
var request = new SetSqueakProfileSharingRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(squeakAddress);
|
||||
request.setSharing(sharing);
|
||||
makeRequest(
|
||||
'setsqueakprofilesharing',
|
||||
|
|
@ -275,9 +273,9 @@ export function setSqueakProfileSharingRequest(id, sharing, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function renameSqueakProfileRequest(id, profileName, handleResponse) {
|
||||
export function renameSqueakProfileRequest(squeakAddress, profileName, handleResponse) {
|
||||
var request = new RenameSqueakProfileRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileName(profileName);
|
||||
makeRequest(
|
||||
'renamesqueakprofile',
|
||||
|
|
@ -287,9 +285,9 @@ export function renameSqueakProfileRequest(id, profileName, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function setSqueakProfileImageRequest(id, profileImage, handleResponse) {
|
||||
export function setSqueakProfileImageRequest(squeakAddress, profileImage, handleResponse) {
|
||||
var request = new SetSqueakProfileImageRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileImage(profileImage);
|
||||
makeRequest(
|
||||
'setsqueakprofileimage',
|
||||
|
|
@ -299,9 +297,9 @@ export function setSqueakProfileImageRequest(id, profileImage, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function clearSqueakProfileImageRequest(id, handleResponse) {
|
||||
export function clearSqueakProfileImageRequest(squeakAddress, handleResponse) {
|
||||
var request = new ClearSqueakProfileImageRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(squeakAddress);
|
||||
makeRequest(
|
||||
'clearsqueakprofileimage',
|
||||
request,
|
||||
|
|
@ -475,9 +473,9 @@ export function getContactProfilesRequest(handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function makeSqueakRequest(profileId, content, replyto, handleResponse, handleErr) {
|
||||
export function makeSqueakRequest(squeakAddress, content, replyto, handleResponse, handleErr) {
|
||||
var request = new MakeSqueakRequest();
|
||||
request.setProfileId(profileId);
|
||||
request.setAddress(squeakAddress);
|
||||
request.setContent(content);
|
||||
request.setReplyto(replyto);
|
||||
makeRequest(
|
||||
|
|
@ -528,19 +526,6 @@ export function getReplySqueakDisplaysRequest(hash, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getSqueakProfileByAddressRequest(address, handleResponse) {
|
||||
var request = new GetSqueakProfileByAddressRequest();
|
||||
request.setAddress(address);
|
||||
makeRequest(
|
||||
'getsqueakprofilebyaddress',
|
||||
request,
|
||||
GetSqueakProfileByAddressReply.deserializeBinary,
|
||||
(response) => {
|
||||
handleResponse(response.getSqueakProfile());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getAddressSqueakDisplaysRequest(address, handleResponse) {
|
||||
var request = new GetAddressSqueakDisplaysRequest();
|
||||
request.setAddress(address);
|
||||
|
|
@ -616,9 +601,9 @@ export function deletePeerRequest(peerId, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function deleteProfileRequest(profileId, handleResponse) {
|
||||
export function deleteProfileRequest(squeakAddress, handleResponse) {
|
||||
var request = new DeleteSqueakProfileRequest();
|
||||
request.setProfileId(profileId);
|
||||
request.setAddress(squeakAddress);
|
||||
makeRequest(
|
||||
'deleteprofile',
|
||||
request,
|
||||
|
|
@ -732,9 +717,9 @@ export function getNetworkRequest(handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getSqueakProfilePrivateKey(id, handleResponse) {
|
||||
export function getSqueakProfilePrivateKey(squeakAddress, handleResponse) {
|
||||
var request = new GetSqueakProfilePrivateKeyRequest();
|
||||
request.setProfileId(id);
|
||||
request.setAddress(squeakAddress);
|
||||
makeRequest(
|
||||
'getsqueakprofileprivatekey',
|
||||
request,
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ def following_signing_key(server_stub, admin_stub):
|
|||
address=profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -87,7 +87,7 @@ def nonfollowing_signing_key(server_stub, admin_stub):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def signing_profile_id(server_stub, admin_stub):
|
||||
def signing_profile_address(server_stub, admin_stub):
|
||||
# Create a new signing profile
|
||||
profile_name = "fake_signing_profile_{}".format(uuid.uuid1())
|
||||
create_signing_profile_response = admin_stub.CreateSigningProfile(
|
||||
|
|
@ -95,12 +95,12 @@ def signing_profile_id(server_stub, admin_stub):
|
|||
profile_name=profile_name,
|
||||
)
|
||||
)
|
||||
profile_id = create_signing_profile_response.profile_id
|
||||
yield profile_id
|
||||
profile_address = create_signing_profile_response.address
|
||||
yield profile_address
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def contact_profile_id(server_stub, admin_stub):
|
||||
def contact_profile_address(server_stub, admin_stub):
|
||||
# Create a new contact profile
|
||||
contact_name = "fake_contact_profile_{}".format(uuid.uuid1())
|
||||
contact_signing_key = generate_signing_key()
|
||||
|
|
@ -111,17 +111,17 @@ def contact_profile_id(server_stub, admin_stub):
|
|||
address=contact_address,
|
||||
)
|
||||
)
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
yield contact_profile_id
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
yield contact_profile_address
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def saved_squeak_hash(server_stub, admin_stub, signing_profile_id):
|
||||
def saved_squeak_hash(server_stub, admin_stub, signing_profile_address):
|
||||
# Create a new squeak using the new profile
|
||||
make_squeak_content = "Hello from the profile on the server!"
|
||||
make_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
content=make_squeak_content,
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,19 +33,19 @@ def test_get_network(admin_stub):
|
|||
assert network == "simnet"
|
||||
|
||||
|
||||
def test_get_profile(server_stub, admin_stub, signing_profile_id):
|
||||
def test_get_profile(server_stub, admin_stub, signing_profile_address):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
address = get_squeak_profile_response.squeak_profile.address
|
||||
name = get_squeak_profile_response.squeak_profile.profile_name
|
||||
|
||||
# Get the same squeak profile by address
|
||||
get_squeak_profile_by_address_response = admin_stub.GetSqueakProfileByAddress(
|
||||
squeak_admin_pb2.GetSqueakProfileByAddressRequest(
|
||||
get_squeak_profile_by_address_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=address,
|
||||
)
|
||||
)
|
||||
|
|
@ -104,11 +104,11 @@ def test_post_squeak_not_following(
|
|||
squeak_server_pb2.UploadSqueakRequest(squeak=squeak_msg))
|
||||
|
||||
|
||||
def test_lookup_squeaks(server_stub, admin_stub, signing_profile_id, saved_squeak_hash):
|
||||
def test_lookup_squeaks(server_stub, admin_stub, signing_profile_address, saved_squeak_hash):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -145,12 +145,12 @@ def test_lookup_squeaks_empty_result_addresses(server_stub, admin_stub):
|
|||
|
||||
|
||||
def test_lookup_squeaks_empty_result_block_ranges(
|
||||
server_stub, admin_stub, signing_profile_id
|
||||
server_stub, admin_stub, signing_profile_address
|
||||
):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -168,11 +168,11 @@ def test_lookup_squeaks_empty_result_block_ranges(
|
|||
assert len(lookup_response.hashes) == 0
|
||||
|
||||
|
||||
def test_lookup_squeaks_to_upload(server_stub, admin_stub, signing_profile_id, saved_squeak_hash):
|
||||
def test_lookup_squeaks_to_upload(server_stub, admin_stub, signing_profile_address, saved_squeak_hash):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -249,12 +249,12 @@ def test_sell_squeak(server_stub, admin_stub, lightning_client, saved_squeak_has
|
|||
assert final_server_balance - initial_server_balance == 1000
|
||||
|
||||
|
||||
def test_make_squeak(server_stub, admin_stub, signing_profile_id):
|
||||
def test_make_squeak(server_stub, admin_stub, signing_profile_address):
|
||||
# Create a new squeak using the new profile
|
||||
make_squeak_content = "Hello from the profile on the server!"
|
||||
make_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
content=make_squeak_content,
|
||||
)
|
||||
)
|
||||
|
|
@ -289,7 +289,7 @@ def test_make_squeak(server_stub, admin_stub, signing_profile_id):
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -309,12 +309,12 @@ def test_make_squeak(server_stub, admin_stub, signing_profile_id):
|
|||
|
||||
|
||||
def test_make_reply_squeak(
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_id
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_address
|
||||
):
|
||||
# Make another squeak as a reply
|
||||
reply_1_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
content="Reply #1",
|
||||
replyto=saved_squeak_hash,
|
||||
)
|
||||
|
|
@ -324,7 +324,7 @@ def test_make_reply_squeak(
|
|||
# Make a second squeak as a reply
|
||||
reply_2_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
content="Reply #2",
|
||||
replyto=reply_1_squeak_hash,
|
||||
)
|
||||
|
|
@ -393,12 +393,12 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
profile_name=profile_name,
|
||||
)
|
||||
)
|
||||
profile_id = create_signing_profile_response.profile_id
|
||||
profile_address = create_signing_profile_response.address
|
||||
|
||||
# Get the new squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=profile_id,
|
||||
address=profile_address,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.profile_name == profile_name
|
||||
|
|
@ -415,8 +415,8 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
assert profile_name in signing_profile_names
|
||||
|
||||
# Get squeak profile by address
|
||||
get_profile_by_address_response = admin_stub.GetSqueakProfileByAddress(
|
||||
squeak_admin_pb2.GetSqueakProfileByAddressRequest(
|
||||
get_profile_by_address_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=squeak_profile_address
|
||||
)
|
||||
)
|
||||
|
|
@ -425,13 +425,13 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
# Export the private key, delete the profile, and re-import it.
|
||||
get_private_key_response = admin_stub.GetSqueakProfilePrivateKey(
|
||||
squeak_admin_pb2.GetSqueakProfilePrivateKeyRequest(
|
||||
profile_id=profile_id,
|
||||
address=profile_address,
|
||||
)
|
||||
)
|
||||
private_key = get_private_key_response.private_key
|
||||
admin_stub.DeleteSqueakProfile(
|
||||
squeak_admin_pb2.DeleteSqueakProfileRequest(
|
||||
profile_id=profile_id,
|
||||
address=profile_address,
|
||||
)
|
||||
)
|
||||
import_response = admin_stub.ImportSigningProfile(
|
||||
|
|
@ -440,12 +440,12 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
private_key=private_key,
|
||||
)
|
||||
)
|
||||
new_profile_id = import_response.profile_id
|
||||
new_profile_address = import_response.address
|
||||
|
||||
# Get the new imported profile
|
||||
get_imported_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=new_profile_id,
|
||||
address=new_profile_address,
|
||||
)
|
||||
)
|
||||
assert get_imported_squeak_profile_response.squeak_profile.profile_name == "imported_profile_name"
|
||||
|
|
@ -463,7 +463,7 @@ def test_make_contact_profile(server_stub, admin_stub):
|
|||
address=contact_address,
|
||||
)
|
||||
)
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
|
||||
# Get all contact profiles
|
||||
get_contact_profiles_response = admin_stub.GetContactProfiles(
|
||||
|
|
@ -473,12 +473,12 @@ def test_make_contact_profile(server_stub, admin_stub):
|
|||
profile.profile_name
|
||||
for profile in get_contact_profiles_response.squeak_profiles
|
||||
]
|
||||
contact_profile_ids = [
|
||||
profile.profile_id
|
||||
contact_profile_addresss = [
|
||||
profile.address
|
||||
for profile in get_contact_profiles_response.squeak_profiles
|
||||
]
|
||||
assert contact_name in contact_profile_names
|
||||
assert contact_profile_id in contact_profile_ids
|
||||
assert contact_profile_address in contact_profile_addresss
|
||||
|
||||
|
||||
def test_make_signing_profile_empty_name(server_stub, admin_stub):
|
||||
|
|
@ -506,11 +506,11 @@ def test_make_contact_profile_empty_name(server_stub, admin_stub):
|
|||
assert "Profile name cannot be empty." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_set_profile_following(server_stub, admin_stub, contact_profile_id):
|
||||
def test_set_profile_following(server_stub, admin_stub, contact_profile_address):
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -518,7 +518,7 @@ def test_set_profile_following(server_stub, admin_stub, contact_profile_id):
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.following
|
||||
|
|
@ -526,7 +526,7 @@ def test_set_profile_following(server_stub, admin_stub, contact_profile_id):
|
|||
# Set the profile to be not following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
following=False,
|
||||
)
|
||||
)
|
||||
|
|
@ -534,17 +534,17 @@ def test_set_profile_following(server_stub, admin_stub, contact_profile_id):
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
assert not get_squeak_profile_response.squeak_profile.following
|
||||
|
||||
|
||||
def test_set_profile_sharing(server_stub, admin_stub, contact_profile_id):
|
||||
def test_set_profile_sharing(server_stub, admin_stub, contact_profile_address):
|
||||
# Set the profile to be sharing
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -552,7 +552,7 @@ def test_set_profile_sharing(server_stub, admin_stub, contact_profile_id):
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.sharing
|
||||
|
|
@ -560,7 +560,7 @@ def test_set_profile_sharing(server_stub, admin_stub, contact_profile_id):
|
|||
# Set the profile to be not sharing
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
sharing=False,
|
||||
)
|
||||
)
|
||||
|
|
@ -568,17 +568,17 @@ def test_set_profile_sharing(server_stub, admin_stub, contact_profile_id):
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
assert not get_squeak_profile_response.squeak_profile.sharing
|
||||
|
||||
|
||||
def test_rename_profile(server_stub, admin_stub, contact_profile_id, random_name):
|
||||
def test_rename_profile(server_stub, admin_stub, contact_profile_address, random_name):
|
||||
# Rename the profile to something new
|
||||
admin_stub.RenameSqueakProfile(
|
||||
squeak_admin_pb2.RenameSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
profile_name=random_name,
|
||||
)
|
||||
)
|
||||
|
|
@ -586,19 +586,19 @@ def test_rename_profile(server_stub, admin_stub, contact_profile_id, random_name
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.profile_name == random_name
|
||||
|
||||
|
||||
def test_set_profile_image(server_stub, admin_stub, contact_profile_id, random_image, random_image_base64_string):
|
||||
def test_set_profile_image(server_stub, admin_stub, contact_profile_address, random_image, random_image_base64_string):
|
||||
print("random_image: {}".format(random_image))
|
||||
print("random_image_base64_string: {}".format(random_image_base64_string))
|
||||
# Set the profile image to something new
|
||||
admin_stub.SetSqueakProfileImage(
|
||||
squeak_admin_pb2.SetSqueakProfileImageRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
profile_image=random_image_base64_string,
|
||||
)
|
||||
)
|
||||
|
|
@ -606,7 +606,7 @@ def test_set_profile_image(server_stub, admin_stub, contact_profile_id, random_i
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
print("get_squeak_profile_response.squeak_profile.profile_image: {}".format(
|
||||
|
|
@ -618,14 +618,14 @@ def test_set_profile_image(server_stub, admin_stub, contact_profile_id, random_i
|
|||
# Clear the profile image
|
||||
admin_stub.ClearSqueakProfileImage(
|
||||
squeak_admin_pb2.ClearSqueakProfileImageRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
print("get_squeak_profile_response.squeak_profile.profile_image: {}".format(
|
||||
|
|
@ -635,11 +635,11 @@ def test_set_profile_image(server_stub, admin_stub, contact_profile_id, random_i
|
|||
assert not get_squeak_profile_response.squeak_profile.has_custom_profile_image
|
||||
|
||||
|
||||
def test_delete_profile(server_stub, admin_stub, contact_profile_id):
|
||||
def test_delete_profile(server_stub, admin_stub, contact_profile_address):
|
||||
# Delete the profile
|
||||
admin_stub.DeleteSqueakProfile(
|
||||
squeak_admin_pb2.DeleteSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -647,17 +647,17 @@ def test_delete_profile(server_stub, admin_stub, contact_profile_id):
|
|||
with pytest.raises(Exception) as excinfo:
|
||||
admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
)
|
||||
)
|
||||
assert "Profile not found." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_get_profile_private_key(server_stub, admin_stub, signing_profile_id):
|
||||
def test_get_profile_private_key(server_stub, admin_stub, signing_profile_address):
|
||||
# Get the private key
|
||||
private_key_response = admin_stub.GetSqueakProfilePrivateKey(
|
||||
squeak_admin_pb2.GetSqueakProfilePrivateKeyRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -666,12 +666,12 @@ def test_get_profile_private_key(server_stub, admin_stub, signing_profile_id):
|
|||
|
||||
|
||||
def test_get_following_squeaks(
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_id
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_address
|
||||
):
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -685,7 +685,7 @@ def test_get_following_squeaks(
|
|||
squeak_display_entry
|
||||
) in get_timeline_squeak_display_response.squeak_display_entries:
|
||||
# TODO: check the profile id of the squeak display entry
|
||||
# assert squeak_display_entry.profile_id == signing_profile_id
|
||||
# assert squeak_display_entry.address == signing_profile_address
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -1026,7 +1026,7 @@ def test_connect_other_node(
|
|||
other_server_stub,
|
||||
other_admin_stub,
|
||||
lightning_client,
|
||||
signing_profile_id,
|
||||
signing_profile_address,
|
||||
saved_squeak_hash,
|
||||
):
|
||||
# Get all squeak displays
|
||||
|
|
@ -1056,7 +1056,7 @@ def test_connect_other_node(
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -1070,7 +1070,7 @@ def test_connect_other_node(
|
|||
# Set the signing profile to be sharing on the main server
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1082,10 +1082,10 @@ def test_connect_other_node(
|
|||
address=squeak_profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
other_admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1233,7 +1233,7 @@ def test_download_single_squeak(
|
|||
other_server_stub,
|
||||
other_admin_stub,
|
||||
lightning_client,
|
||||
signing_profile_id,
|
||||
signing_profile_address,
|
||||
saved_squeak_hash,
|
||||
):
|
||||
|
||||
|
|
@ -1258,7 +1258,7 @@ def test_download_single_squeak(
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -1272,7 +1272,7 @@ def test_download_single_squeak(
|
|||
# Set the signing profile to be sharing on the main server
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
profile_id=signing_profile_id,
|
||||
address=signing_profile_address,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1284,10 +1284,10 @@ def test_download_single_squeak(
|
|||
address=squeak_profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
other_admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
address=contact_profile_address,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -88,10 +88,6 @@ service SqueakAdmin {
|
|||
*/
|
||||
rpc GetSqueakProfile (GetSqueakProfileRequest) returns (GetSqueakProfileReply) {}
|
||||
|
||||
/** sqkadmin: `getsqueakprofilebyaddress`
|
||||
*/
|
||||
rpc GetSqueakProfileByAddress (GetSqueakProfileByAddressRequest) returns (GetSqueakProfileByAddressReply) {}
|
||||
|
||||
/** sqkadmin: `getsqueakprofilebyname`
|
||||
*/
|
||||
rpc GetSqueakProfileByName (GetSqueakProfileByNameRequest) returns (GetSqueakProfileByNameReply) {}
|
||||
|
|
@ -240,8 +236,8 @@ message CreateSigningProfileRequest {
|
|||
}
|
||||
|
||||
message CreateSigningProfileReply {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message ImportSigningProfileRequest {
|
||||
|
|
@ -253,8 +249,8 @@ message ImportSigningProfileRequest {
|
|||
}
|
||||
|
||||
message ImportSigningProfileReply {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message CreateContactProfileRequest {
|
||||
|
|
@ -266,8 +262,8 @@ message CreateContactProfileRequest {
|
|||
}
|
||||
|
||||
message CreateContactProfileReply {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message GetSigningProfilesRequest {
|
||||
|
|
@ -287,21 +283,11 @@ message GetContactProfilesReply {
|
|||
}
|
||||
|
||||
message GetSqueakProfileRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileReply {
|
||||
/// The squeak profile
|
||||
SqueakProfile squeak_profile = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileByAddressRequest {
|
||||
/// The address
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileByAddressReply {
|
||||
message GetSqueakProfileReply {
|
||||
/// The squeak profile
|
||||
SqueakProfile squeak_profile = 1;
|
||||
}
|
||||
|
|
@ -317,8 +303,8 @@ message GetSqueakProfileByNameReply {
|
|||
}
|
||||
|
||||
message SetSqueakProfileFollowingRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
|
||||
/// Following
|
||||
bool following = 2;
|
||||
|
|
@ -328,8 +314,8 @@ message SetSqueakProfileFollowingReply {
|
|||
}
|
||||
|
||||
message SetSqueakProfileSharingRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
|
||||
/// Sharing
|
||||
bool sharing = 2;
|
||||
|
|
@ -339,8 +325,8 @@ message SetSqueakProfileSharingReply {
|
|||
}
|
||||
|
||||
message RenameSqueakProfileRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
|
||||
/// The new profile name
|
||||
string profile_name = 2;
|
||||
|
|
@ -350,8 +336,8 @@ message RenameSqueakProfileReply {
|
|||
}
|
||||
|
||||
message GetSqueakProfilePrivateKeyRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfilePrivateKeyReply {
|
||||
|
|
@ -360,16 +346,16 @@ message GetSqueakProfilePrivateKeyReply {
|
|||
}
|
||||
|
||||
message DeleteSqueakProfileRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message DeleteSqueakProfileReply {
|
||||
}
|
||||
|
||||
message SetSqueakProfileImageRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
|
||||
/// The profile image
|
||||
string profile_image = 2;
|
||||
|
|
@ -379,16 +365,16 @@ message SetSqueakProfileImageReply {
|
|||
}
|
||||
|
||||
message ClearSqueakProfileImageRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message ClearSqueakProfileImageReply {
|
||||
}
|
||||
|
||||
message SqueakProfile {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The address
|
||||
string address = 1;
|
||||
|
||||
/// The profile name
|
||||
string profile_name = 2;
|
||||
|
|
@ -396,25 +382,22 @@ message SqueakProfile {
|
|||
/// Has private key
|
||||
bool has_private_key = 3;
|
||||
|
||||
/// The address
|
||||
string address = 4;
|
||||
|
||||
/// Sharing
|
||||
bool sharing = 5;
|
||||
bool sharing = 4;
|
||||
|
||||
/// Following
|
||||
bool following = 6;
|
||||
bool following = 5;
|
||||
|
||||
/// The profile image
|
||||
string profile_image = 7;
|
||||
string profile_image = 6;
|
||||
|
||||
/// Has custom profile image
|
||||
bool has_custom_profile_image = 8;
|
||||
bool has_custom_profile_image = 7;
|
||||
}
|
||||
|
||||
message MakeSqueakRequest {
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
|
||||
/// The content
|
||||
string content = 2;
|
||||
|
|
|
|||
|
|
@ -52,17 +52,14 @@ def squeak_entry_to_message(squeak_entry_with_profile: SqueakEntryWithProfile) -
|
|||
|
||||
|
||||
def squeak_profile_to_message(squeak_profile: SqueakProfile) -> squeak_admin_pb2.SqueakProfile:
|
||||
if squeak_profile.profile_id is None:
|
||||
raise Exception("Profile id cannot be None.")
|
||||
has_private_key = squeak_profile.private_key is not None
|
||||
profile_image = squeak_profile.profile_image or DEFAULT_PROFILE_IMAGE
|
||||
has_custom_profile_image = squeak_profile.profile_image is not None
|
||||
image_base64_str = bytes_to_base64_string(profile_image)
|
||||
return squeak_admin_pb2.SqueakProfile(
|
||||
profile_id=squeak_profile.profile_id,
|
||||
address=squeak_profile.address,
|
||||
profile_name=squeak_profile.profile_name,
|
||||
has_private_key=has_private_key,
|
||||
address=squeak_profile.address,
|
||||
sharing=squeak_profile.sharing,
|
||||
following=squeak_profile.following,
|
||||
profile_image=image_base64_str,
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ class SqueakAdminServerHandler(object):
|
|||
profile_name = request.profile_name
|
||||
logger.info(
|
||||
"Handle create signing profile with name: {}".format(profile_name))
|
||||
profile_id = self.squeak_controller.create_signing_profile(
|
||||
address = self.squeak_controller.create_signing_profile(
|
||||
profile_name)
|
||||
logger.info("New profile_id: {}".format(profile_id))
|
||||
logger.info("New profile address: {}".format(address))
|
||||
return squeak_admin_pb2.CreateSigningProfileReply(
|
||||
profile_id=profile_id,
|
||||
address=address,
|
||||
)
|
||||
|
||||
def handle_import_signing_profile(self, request):
|
||||
|
|
@ -100,11 +100,11 @@ class SqueakAdminServerHandler(object):
|
|||
private_key = request.private_key
|
||||
logger.info(
|
||||
"Handle import signing profile with name: {}".format(profile_name))
|
||||
profile_id = self.squeak_controller.import_signing_profile(
|
||||
address = self.squeak_controller.import_signing_profile(
|
||||
profile_name, private_key)
|
||||
logger.info("New profile_id: {}".format(profile_id))
|
||||
logger.info("New profile address: {}".format(address))
|
||||
return squeak_admin_pb2.ImportSigningProfileReply(
|
||||
profile_id=profile_id,
|
||||
address=address,
|
||||
)
|
||||
|
||||
def handle_create_contact_profile(self, request):
|
||||
|
|
@ -116,12 +116,12 @@ class SqueakAdminServerHandler(object):
|
|||
squeak_address,
|
||||
)
|
||||
)
|
||||
profile_id = self.squeak_controller.create_contact_profile(
|
||||
address = self.squeak_controller.create_contact_profile(
|
||||
profile_name, squeak_address
|
||||
)
|
||||
logger.info("New profile_id: {}".format(profile_id))
|
||||
logger.info("New profile address: {}".format(address))
|
||||
return squeak_admin_pb2.CreateContactProfileReply(
|
||||
profile_id=profile_id,
|
||||
address=address,
|
||||
)
|
||||
|
||||
def handle_get_signing_profiles(self, request):
|
||||
|
|
@ -141,9 +141,10 @@ class SqueakAdminServerHandler(object):
|
|||
return squeak_admin_pb2.GetContactProfilesReply(squeak_profiles=profile_msgs)
|
||||
|
||||
def handle_get_squeak_profile(self, request):
|
||||
profile_id = request.profile_id
|
||||
logger.info("Handle get squeak profile with id: {}".format(profile_id))
|
||||
squeak_profile = self.squeak_controller.get_squeak_profile(profile_id)
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle get squeak profile with address: {}".format(address))
|
||||
squeak_profile = self.squeak_controller.get_squeak_profile(address)
|
||||
if squeak_profile is None:
|
||||
raise Exception("Profile not found.")
|
||||
squeak_profile_msg = squeak_profile_to_message(squeak_profile)
|
||||
|
|
@ -151,19 +152,6 @@ class SqueakAdminServerHandler(object):
|
|||
squeak_profile=squeak_profile_msg,
|
||||
)
|
||||
|
||||
def handle_get_squeak_profile_by_address(self, request):
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle get squeak profile with address: {}".format(address))
|
||||
squeak_profile = self.squeak_controller.get_squeak_profile_by_address(
|
||||
address)
|
||||
if squeak_profile is None:
|
||||
raise Exception("Profile not found.")
|
||||
squeak_profile_msg = squeak_profile_to_message(squeak_profile)
|
||||
return squeak_admin_pb2.GetSqueakProfileByAddressReply(
|
||||
squeak_profile=squeak_profile_msg
|
||||
)
|
||||
|
||||
def handle_get_squeak_profile_by_name(self, request):
|
||||
name = request.name
|
||||
logger.info("Handle get squeak profile with name: {}".format(name))
|
||||
|
|
@ -177,93 +165,94 @@ class SqueakAdminServerHandler(object):
|
|||
)
|
||||
|
||||
def handle_set_squeak_profile_following(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
following = request.following
|
||||
logger.info(
|
||||
"Handle set squeak profile following with profile id: {}, following: {}".format(
|
||||
profile_id,
|
||||
address,
|
||||
following,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.set_squeak_profile_following(
|
||||
profile_id, following)
|
||||
address, following)
|
||||
return squeak_admin_pb2.SetSqueakProfileFollowingReply()
|
||||
|
||||
def handle_set_squeak_profile_sharing(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
sharing = request.sharing
|
||||
logger.info(
|
||||
"Handle set squeak profile sharing with profile id: {}, sharing: {}".format(
|
||||
profile_id,
|
||||
address,
|
||||
sharing,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.set_squeak_profile_sharing(profile_id, sharing)
|
||||
self.squeak_controller.set_squeak_profile_sharing(address, sharing)
|
||||
return squeak_admin_pb2.SetSqueakProfileSharingReply()
|
||||
|
||||
def handle_rename_squeak_profile(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
profile_name = request.profile_name
|
||||
logger.info(
|
||||
"Handle rename squeak profile with profile id: {}, new name: {}".format(
|
||||
profile_id,
|
||||
address,
|
||||
profile_name,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.rename_squeak_profile(profile_id, profile_name)
|
||||
self.squeak_controller.rename_squeak_profile(address, profile_name)
|
||||
return squeak_admin_pb2.RenameSqueakProfileReply()
|
||||
|
||||
def handle_delete_squeak_profile(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle delete squeak profile with id: {}".format(profile_id))
|
||||
self.squeak_controller.delete_squeak_profile(profile_id)
|
||||
"Handle delete squeak profile with address: {}".format(address))
|
||||
self.squeak_controller.delete_squeak_profile(address)
|
||||
return squeak_admin_pb2.DeleteSqueakProfileReply()
|
||||
|
||||
def handle_set_squeak_profile_image(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
profile_image = request.profile_image
|
||||
logger.info(
|
||||
"Handle set squeak profile image with profile id: {}".format(
|
||||
profile_id,
|
||||
address,
|
||||
)
|
||||
)
|
||||
profile_image_bytes = base64_string_to_bytes(profile_image)
|
||||
self.squeak_controller.set_squeak_profile_image(
|
||||
profile_id, profile_image_bytes)
|
||||
address, profile_image_bytes)
|
||||
return squeak_admin_pb2.SetSqueakProfileImageReply()
|
||||
|
||||
def handle_clear_squeak_profile_image(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle clear squeak profile image with profile id: {}".format(
|
||||
profile_id,
|
||||
address,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.clear_squeak_profile_image(
|
||||
profile_id,
|
||||
address,
|
||||
)
|
||||
return squeak_admin_pb2.ClearSqueakProfileImageReply()
|
||||
|
||||
def handle_get_squeak_profile_private_key(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle get squeak profile private key for id: {}".format(profile_id))
|
||||
"Handle get squeak profile private key for id: {}".format(address))
|
||||
private_key = self.squeak_controller.get_squeak_profile_private_key(
|
||||
profile_id)
|
||||
address)
|
||||
return squeak_admin_pb2.GetSqueakProfilePrivateKeyReply(
|
||||
private_key=private_key
|
||||
)
|
||||
|
||||
def handle_make_squeak(self, request):
|
||||
profile_id = request.profile_id
|
||||
address = request.address
|
||||
content_str = request.content
|
||||
replyto_hash_str = request.replyto
|
||||
replyto_hash = bytes.fromhex(
|
||||
replyto_hash_str) if replyto_hash_str else None
|
||||
logger.info("Handle make squeak profile with id: {}".format(profile_id))
|
||||
logger.info(
|
||||
"Handle make squeak profile with address: {}".format(address))
|
||||
inserted_squeak_hash = self.squeak_controller.make_squeak(
|
||||
profile_id, content_str, replyto_hash
|
||||
address, content_str, replyto_hash
|
||||
)
|
||||
return squeak_admin_pb2.MakeSqueakReply(
|
||||
squeak_hash=inserted_squeak_hash.hex(),
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
return squeak_admin_pb2.GetSqueakProfileReply()
|
||||
return reply
|
||||
|
||||
def GetSqueakProfileByAddress(self, request, context):
|
||||
return self.handler.handle_get_squeak_profile_by_address(request)
|
||||
|
||||
def GetSqueakProfileByName(self, request, context):
|
||||
return self.handler.handle_get_squeak_profile_by_name(request)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"files": {
|
||||
"main.js": "/static/js/main.74560df3.chunk.js",
|
||||
"main.js.map": "/static/js/main.74560df3.chunk.js.map",
|
||||
"main.js": "/static/js/main.ee717f0e.chunk.js",
|
||||
"main.js.map": "/static/js/main.ee717f0e.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.9f0ba400.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.9f0ba400.js.map",
|
||||
"static/css/2.15110fae.chunk.css": "/static/css/2.15110fae.chunk.css",
|
||||
"static/js/2.ee5e70e8.chunk.js": "/static/js/2.ee5e70e8.chunk.js",
|
||||
"static/js/2.ee5e70e8.chunk.js.map": "/static/js/2.ee5e70e8.chunk.js.map",
|
||||
"static/js/2.b63efdf4.chunk.js": "/static/js/2.b63efdf4.chunk.js",
|
||||
"static/js/2.b63efdf4.chunk.js.map": "/static/js/2.b63efdf4.chunk.js.map",
|
||||
"index.html": "/index.html",
|
||||
"precache-manifest.72a3118e05450807c47caf4b92918296.js": "/precache-manifest.72a3118e05450807c47caf4b92918296.js",
|
||||
"precache-manifest.f9b934a54528388a8486cbcc464feb61.js": "/precache-manifest.f9b934a54528388a8486cbcc464feb61.js",
|
||||
"service-worker.js": "/service-worker.js",
|
||||
"static/css/2.15110fae.chunk.css.map": "/static/css/2.15110fae.chunk.css.map",
|
||||
"static/js/2.ee5e70e8.chunk.js.LICENSE.txt": "/static/js/2.ee5e70e8.chunk.js.LICENSE.txt",
|
||||
"static/js/2.b63efdf4.chunk.js.LICENSE.txt": "/static/js/2.b63efdf4.chunk.js.LICENSE.txt",
|
||||
"static/media/font-awesome.min.css": "/static/media/fontawesome-webfont.fee66e71.woff",
|
||||
"static/media/google.svg": "/static/media/google.695a3160.svg",
|
||||
"static/media/logo.svg": "/static/media/logo.a0185b04.svg"
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"entrypoints": [
|
||||
"static/js/runtime-main.9f0ba400.js",
|
||||
"static/css/2.15110fae.chunk.css",
|
||||
"static/js/2.ee5e70e8.chunk.js",
|
||||
"static/js/main.74560df3.chunk.js"
|
||||
"static/js/2.b63efdf4.chunk.js",
|
||||
"static/js/main.ee717f0e.chunk.js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.ee5e70e8.chunk.js"></script><script src="/static/js/main.74560df3.chunk.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.b63efdf4.chunk.js"></script><script src="/static/js/main.ee717f0e.chunk.js"></script></body></html>
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
self.__precacheManifest = (self.__precacheManifest || []).concat([
|
||||
{
|
||||
"revision": "4e358f2c6b161f761432c8a8bb6873fa",
|
||||
"revision": "48911a66e2a1038ab0c4ac380c85c0d0",
|
||||
"url": "/index.html"
|
||||
},
|
||||
{
|
||||
"revision": "3c94c4e3efa056791ec1",
|
||||
"revision": "a10df19718592a5c7206",
|
||||
"url": "/static/css/2.15110fae.chunk.css"
|
||||
},
|
||||
{
|
||||
"revision": "3c94c4e3efa056791ec1",
|
||||
"url": "/static/js/2.ee5e70e8.chunk.js"
|
||||
"revision": "a10df19718592a5c7206",
|
||||
"url": "/static/js/2.b63efdf4.chunk.js"
|
||||
},
|
||||
{
|
||||
"revision": "7156b2c9571000777b9be03b3c6006ee",
|
||||
"url": "/static/js/2.ee5e70e8.chunk.js.LICENSE.txt"
|
||||
"url": "/static/js/2.b63efdf4.chunk.js.LICENSE.txt"
|
||||
},
|
||||
{
|
||||
"revision": "db4334b24ecdf72a3d02",
|
||||
"url": "/static/js/main.74560df3.chunk.js"
|
||||
"revision": "117afa0879b90eb74ecf",
|
||||
"url": "/static/js/main.ee717f0e.chunk.js"
|
||||
},
|
||||
{
|
||||
"revision": "cc9816de5a8639d377ea",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
|
||||
|
||||
importScripts(
|
||||
"/precache-manifest.72a3118e05450807c47caf4b92918296.js"
|
||||
"/precache-manifest.f9b934a54528388a8486cbcc464feb61.js"
|
||||
);
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -130,7 +130,6 @@ class SqueakController:
|
|||
signing_key_str = str(signing_key)
|
||||
signing_key_bytes = signing_key_str.encode()
|
||||
squeak_profile = SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
|
|
@ -147,7 +146,6 @@ class SqueakController:
|
|||
signing_key_str = str(signing_key)
|
||||
signing_key_bytes = signing_key_str.encode()
|
||||
squeak_profile = SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
|
|
@ -169,7 +167,6 @@ class SqueakController:
|
|||
),
|
||||
)
|
||||
squeak_profile = SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=None,
|
||||
address=squeak_address,
|
||||
|
|
@ -185,44 +182,41 @@ class SqueakController:
|
|||
def get_contact_profiles(self):
|
||||
return self.squeak_db.get_contact_profiles()
|
||||
|
||||
def get_squeak_profile(self, profile_id: int):
|
||||
return self.squeak_db.get_profile(profile_id)
|
||||
|
||||
def get_squeak_profile_by_address(self, address: str):
|
||||
return self.squeak_db.get_profile_by_address(address)
|
||||
def get_squeak_profile(self, address: str):
|
||||
return self.squeak_db.get_profile(address)
|
||||
|
||||
def get_squeak_profile_by_name(self, name: str):
|
||||
return self.squeak_db.get_profile_by_name(name)
|
||||
|
||||
def set_squeak_profile_following(self, profile_id: int, following: bool):
|
||||
self.squeak_db.set_profile_following(profile_id, following)
|
||||
def set_squeak_profile_following(self, address: str, following: bool):
|
||||
self.squeak_db.set_profile_following(address, following)
|
||||
self.squeak_whitelist.refresh()
|
||||
|
||||
def set_squeak_profile_sharing(self, profile_id: int, sharing: bool):
|
||||
self.squeak_db.set_profile_sharing(profile_id, sharing)
|
||||
def set_squeak_profile_sharing(self, address: str, sharing: bool):
|
||||
self.squeak_db.set_profile_sharing(address, sharing)
|
||||
|
||||
def rename_squeak_profile(self, profile_id: int, profile_name: str):
|
||||
self.squeak_db.set_profile_name(profile_id, profile_name)
|
||||
def rename_squeak_profile(self, address: str, profile_name: str):
|
||||
self.squeak_db.set_profile_name(address, profile_name)
|
||||
|
||||
def delete_squeak_profile(self, profile_id: int):
|
||||
self.squeak_db.delete_profile(profile_id)
|
||||
def delete_squeak_profile(self, address: str):
|
||||
self.squeak_db.delete_profile(address)
|
||||
|
||||
def set_squeak_profile_image(self, profile_id: int, profile_image: bytes):
|
||||
self.squeak_db.set_profile_image(profile_id, profile_image)
|
||||
def set_squeak_profile_image(self, address: str, profile_image: bytes):
|
||||
self.squeak_db.set_profile_image(address, profile_image)
|
||||
|
||||
def clear_squeak_profile_image(self, profile_id: int):
|
||||
self.squeak_db.set_profile_image(profile_id, None)
|
||||
def clear_squeak_profile_image(self, address: str):
|
||||
self.squeak_db.set_profile_image(address, None)
|
||||
|
||||
def get_squeak_profile_private_key(self, profile_id: int):
|
||||
profile = self.get_squeak_profile(profile_id)
|
||||
def get_squeak_profile_private_key(self, address: str):
|
||||
profile = self.get_squeak_profile(address)
|
||||
if profile.private_key is None:
|
||||
raise Exception("Profile with id: {} does not have a private key.".format(
|
||||
profile_id
|
||||
raise Exception("Profile with address: {} does not have a private key.".format(
|
||||
address
|
||||
))
|
||||
return profile.private_key
|
||||
|
||||
def make_squeak(self, profile_id: int, content_str: str, replyto_hash: bytes):
|
||||
squeak_profile = self.squeak_db.get_profile(profile_id)
|
||||
def make_squeak(self, address: str, content_str: str, replyto_hash: bytes):
|
||||
squeak_profile = self.squeak_db.get_profile(address)
|
||||
squeak_entry = self.squeak_core.make_squeak(
|
||||
squeak_profile, content_str, replyto_hash)
|
||||
# return self.save_created_squeak(squeak_entry.squeak)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ from typing import Optional
|
|||
|
||||
class SqueakProfile(NamedTuple):
|
||||
"""Represents a user who can author squeaks."""
|
||||
profile_id: Optional[int]
|
||||
address: str
|
||||
profile_name: str
|
||||
private_key: Optional[bytes]
|
||||
address: str
|
||||
sharing: bool
|
||||
following: bool
|
||||
profile_image: Optional[bytes]
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
"""Use explicit sqlite autoincrement
|
||||
|
||||
Revision ID: 4b3084f96b00
|
||||
Revises: 6851569c46e3
|
||||
Create Date: 2021-02-03 02:27:10.910820
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4b3084f96b00'
|
||||
down_revision = '6851569c46e3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
def alter_table_with_sqlite_autoincrement(table_name):
|
||||
with op.batch_alter_table(
|
||||
table_name,
|
||||
recreate="always",
|
||||
table_kwargs={'sqlite_autoincrement': True},
|
||||
schema=None,
|
||||
):
|
||||
pass
|
||||
|
||||
for table in [
|
||||
'profile',
|
||||
'peer',
|
||||
'received_offer',
|
||||
'sent_payment',
|
||||
'sent_offer',
|
||||
'received_payment',
|
||||
]:
|
||||
alter_table_with_sqlite_autoincrement(table)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
def alter_table_without_sqlite_autoincrement(table_name):
|
||||
with op.batch_alter_table(
|
||||
table_name,
|
||||
recreate="always",
|
||||
table_kwargs={'sqlite_autoincrement': True},
|
||||
schema=None,
|
||||
):
|
||||
pass
|
||||
|
||||
for table in [
|
||||
'profile',
|
||||
'peer',
|
||||
'received_offer',
|
||||
'sent_payment',
|
||||
'sent_offer',
|
||||
'received_payment',
|
||||
]:
|
||||
alter_table_without_sqlite_autoincrement(table)
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
"""Use address for profile primary key
|
||||
|
||||
Revision ID: d1cf733279c4
|
||||
Revises: 6851569c46e3
|
||||
Create Date: 2021-02-02 17:12:40.262077
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd1cf733279c4'
|
||||
down_revision = '6851569c46e3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('profile', schema=None) as batch_op:
|
||||
batch_op.drop_column('profile_id')
|
||||
batch_op.create_primary_key(
|
||||
"pk_profile", ["address"]
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('profile', schema=None) as batch_op:
|
||||
batch_op.drop_constraint("pk_profile")
|
||||
batch_op.add_column(
|
||||
sa.Column('profile_id', sa.INTEGER(), nullable=False))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -58,16 +58,14 @@ class Models:
|
|||
self.profiles = Table(
|
||||
"profile",
|
||||
self.metadata,
|
||||
Column("profile_id", Integer, primary_key=True),
|
||||
Column("address", String(35), primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("profile_name", String, unique=True, nullable=False),
|
||||
Column("private_key", Binary),
|
||||
Column("address", String(35), unique=True, nullable=False),
|
||||
Column("sharing", Boolean, nullable=False),
|
||||
Column("following", Boolean, nullable=False),
|
||||
Column("profile_image", Binary, nullable=True),
|
||||
sqlite_autoincrement=True,
|
||||
)
|
||||
|
||||
self.peers = Table(
|
||||
|
|
@ -81,7 +79,6 @@ class Models:
|
|||
Column("server_port", Integer, nullable=False),
|
||||
Column("uploading", Boolean, nullable=False),
|
||||
Column("downloading", Boolean, nullable=False),
|
||||
sqlite_autoincrement=True,
|
||||
)
|
||||
|
||||
self.received_offers = Table(
|
||||
|
|
@ -102,7 +99,6 @@ class Models:
|
|||
Column("node_host", String, nullable=False),
|
||||
Column("node_port", Integer, nullable=False),
|
||||
Column("peer_id", Integer, nullable=False),
|
||||
sqlite_autoincrement=True,
|
||||
)
|
||||
|
||||
self.sent_payments = Table(
|
||||
|
|
@ -118,7 +114,6 @@ class Models:
|
|||
Column("price_msat", Integer, nullable=False, default=0),
|
||||
Column("node_pubkey", String(66), nullable=False),
|
||||
Column("valid", Boolean, nullable=False),
|
||||
sqlite_autoincrement=True,
|
||||
)
|
||||
|
||||
self.sent_offers = Table(
|
||||
|
|
@ -137,8 +132,7 @@ class Models:
|
|||
Column("invoice_expiry", Integer, nullable=False),
|
||||
Column("client_addr", String(64), nullable=False),
|
||||
UniqueConstraint('squeak_hash', 'client_addr',
|
||||
name='uq_sent_offer_squeak_hash_client_addr'),
|
||||
sqlite_autoincrement=True,
|
||||
name='uq_sent_offer_squeak_hash_client_addr')
|
||||
)
|
||||
|
||||
self.received_payments = Table(
|
||||
|
|
@ -152,5 +146,4 @@ class Models:
|
|||
Column("price_msat", Integer, nullable=False),
|
||||
Column("settle_index", Integer, nullable=False),
|
||||
Column("client_addr", String(64), nullable=False),
|
||||
sqlite_autoincrement=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ class SqueakDb:
|
|||
# hashes = [bytes.fromhex(row["hash"]) for row in rows]
|
||||
# return hashes
|
||||
|
||||
def insert_profile(self, squeak_profile: SqueakProfile) -> int:
|
||||
def insert_profile(self, squeak_profile: SqueakProfile) -> str:
|
||||
""" Insert a new squeak profile. """
|
||||
ins = self.profiles.insert().values(
|
||||
profile_name=squeak_profile.profile_name,
|
||||
|
|
@ -469,8 +469,8 @@ class SqueakDb:
|
|||
)
|
||||
with self.get_connection() as connection:
|
||||
res = connection.execute(ins)
|
||||
profile_id = res.inserted_primary_key[0]
|
||||
return profile_id
|
||||
address = res.inserted_primary_key[0]
|
||||
return address
|
||||
|
||||
def get_signing_profiles(self) -> List[SqueakProfile]:
|
||||
""" Get all signing profiles. """
|
||||
|
|
@ -541,35 +541,7 @@ class SqueakDb:
|
|||
profiles = [self._parse_squeak_profile(row) for row in rows]
|
||||
return profiles
|
||||
|
||||
# sql = """
|
||||
# SELECT * FROM profile
|
||||
# WHERE sharing;
|
||||
# """
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql)
|
||||
# rows = curs.fetchall()
|
||||
# profiles = [self._parse_squeak_profile(row) for row in rows]
|
||||
# return profiles
|
||||
|
||||
def get_profile(self, profile_id: int) -> Optional[SqueakProfile]:
|
||||
""" Get a profile. """
|
||||
s = select([self.profiles]).where(
|
||||
self.profiles.c.profile_id == profile_id)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
row = result.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return self._parse_squeak_profile(row)
|
||||
|
||||
# sql = """
|
||||
# SELECT * FROM profile WHERE profile_id=%s"""
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (profile_id,))
|
||||
# row = curs.fetchone()
|
||||
# return self._parse_squeak_profile(row)
|
||||
|
||||
def get_profile_by_address(self, address: str) -> Optional[SqueakProfile]:
|
||||
def get_profile(self, address: str) -> Optional[SqueakProfile]:
|
||||
""" Get a profile by address. """
|
||||
s = select([self.profiles]).where(self.profiles.c.address == address)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -598,65 +570,49 @@ class SqueakDb:
|
|||
return None
|
||||
return self._parse_squeak_profile(row)
|
||||
|
||||
def set_profile_following(self, profile_id: int, following: bool):
|
||||
def set_profile_following(self, address: str, following: bool):
|
||||
""" Set a profile is following. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.where(self.profiles.c.address == address)
|
||||
.values(following=following)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
# sql = """
|
||||
# UPDATE profile
|
||||
# SET following=%s
|
||||
# WHERE profile_id=%s;
|
||||
# """
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (following, profile_id,))
|
||||
|
||||
def set_profile_sharing(self, profile_id: int, sharing: bool):
|
||||
def set_profile_sharing(self, address: str, sharing: bool):
|
||||
""" Set a profile is sharing. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.where(self.profiles.c.address == address)
|
||||
.values(sharing=sharing)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
# sql = """
|
||||
# UPDATE profile
|
||||
# SET sharing=%s
|
||||
# WHERE profile_id=%s;
|
||||
# """
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (sharing, profile_id,))
|
||||
|
||||
def set_profile_name(self, profile_id: int, profile_name: str):
|
||||
def set_profile_name(self, address: str, profile_name: str):
|
||||
""" Set a profile name. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.where(self.profiles.c.address == address)
|
||||
.values(profile_name=profile_name)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def delete_profile(self, profile_id: int):
|
||||
def delete_profile(self, address: str):
|
||||
""" Delete a profile. """
|
||||
delete_profile_stmt = self.profiles.delete().where(
|
||||
self.profiles.c.profile_id == profile_id
|
||||
self.profiles.c.address == address
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(delete_profile_stmt)
|
||||
|
||||
def set_profile_image(self, profile_id: int, profile_image: bytes):
|
||||
def set_profile_image(self, address: str, profile_image: bytes):
|
||||
""" Set a profile image. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.where(self.profiles.c.address == address)
|
||||
.values(profile_image=profile_image)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -1154,7 +1110,6 @@ class SqueakDb:
|
|||
private_key_column = row["private_key"]
|
||||
private_key = bytes(private_key_column) if private_key_column else None
|
||||
return SqueakProfile(
|
||||
profile_id=row["profile_id"],
|
||||
profile_name=row["profile_name"],
|
||||
private_key=private_key,
|
||||
address=row["address"],
|
||||
|
|
@ -1165,10 +1120,7 @@ class SqueakDb:
|
|||
|
||||
def _parse_squeak_entry_with_profile(self, row) -> SqueakEntryWithProfile:
|
||||
squeak_entry = self._parse_squeak_entry(row)
|
||||
if row["profile_id"] is None:
|
||||
squeak_profile = None
|
||||
else:
|
||||
squeak_profile = self._parse_squeak_profile(row)
|
||||
squeak_profile = self._parse_squeak_profile(row)
|
||||
return SqueakEntryWithProfile(
|
||||
squeak_entry=squeak_entry,
|
||||
squeak_profile=squeak_profile,
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ def signing_profile():
|
|||
signing_key_str = str(signing_key)
|
||||
signing_key_bytes = signing_key_str.encode()
|
||||
return SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue