added username plugin and api endpoint to get all contacts as opposed to just friends
This commit is contained in:
parent
f74fd0d03d
commit
74db4d2d9d
@ -24,6 +24,15 @@ from coredb import keydb
|
|||||||
friends = Blueprint('friends', __name__)
|
friends = Blueprint('friends', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@friends.route('/friends/listall')
|
||||||
|
def list_all():
|
||||||
|
pubkey_list = {}
|
||||||
|
friend_list = contactmanager.ContactManager.list_friends(0)
|
||||||
|
for friend in friend_list:
|
||||||
|
pubkey_list[friend.publicKey] = {'name': friend.get_info('name')}
|
||||||
|
return json.dumps(pubkey_list)
|
||||||
|
|
||||||
|
|
||||||
@friends.route('/friends/list')
|
@friends.route('/friends/list')
|
||||||
def list_friends():
|
def list_friends():
|
||||||
pubkey_list = {}
|
pubkey_list = {}
|
||||||
|
@ -252,8 +252,8 @@ class OnionrUser:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list_friends(cls):
|
def list_friends(cls, trust_level=1):
|
||||||
friendList = []
|
friendList = []
|
||||||
for x in keydb.listkeys.list_peers(trust=1):
|
for x in keydb.listkeys.list_peers(trust=trust_level):
|
||||||
friendList.append(cls(x))
|
friendList.append(cls(x))
|
||||||
return list(friendList)
|
return list(friendList)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name" : "pms",
|
"name" : "pms",
|
||||||
"version" : "0.1.2",
|
"version" : "0.1.3",
|
||||||
"author" : "onionr"
|
"author" : "onionr"
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import notifier
|
|||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
plugin_name = 'pms'
|
plugin_name = 'pms'
|
||||||
PLUGIN_VERSION = '0.1.2'
|
PLUGIN_VERSION = '0.1.3'
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
||||||
import sentboxdb, mailapi, loadinbox # import after path insert
|
import sentboxdb, mailapi, loadinbox # import after path insert
|
||||||
|
@ -240,7 +240,7 @@
|
|||||||
<div id="sendMessage">
|
<div id="sendMessage">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label><i class="fas fa-user"></i> Select friend: <select id="friendSelect"></select></label>
|
<label><i class="fas fa-user"></i> Select contact: <select id="friendSelect"></select></label>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" action="" id="sendForm" enctype="application/x-www-form-urlencoded">
|
<form method="post" action="" id="sendForm" enctype="application/x-www-form-urlencoded">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -415,7 +415,7 @@ for (var i = 0; i < document.getElementsByClassName('refresh').length; i++){
|
|||||||
document.getElementsByClassName('refresh')[i].style.float = 'right'
|
document.getElementsByClassName('refresh')[i].style.float = 'right'
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('/friends/list', {
|
fetch('/friends/listall', {
|
||||||
headers: {
|
headers: {
|
||||||
"token": webpass
|
"token": webpass
|
||||||
}})
|
}})
|
||||||
|
5
static-data/default-plugins/usernames/info.json
Executable file
5
static-data/default-plugins/usernames/info.json
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"name" : "usernames",
|
||||||
|
"version" : "0.0.0",
|
||||||
|
"author" : "onionr"
|
||||||
|
}
|
42
static-data/default-plugins/usernames/main.py
Executable file
42
static-data/default-plugins/usernames/main.py
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
"""
|
||||||
|
Onionr - Private P2P Communication.
|
||||||
|
|
||||||
|
Preset Onionr usernames
|
||||||
|
"""
|
||||||
|
import locale
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
|
from utils import identifyhome
|
||||||
|
from onionrusers import contactmanager
|
||||||
|
"""
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
|
plugin_name = 'usernames'
|
||||||
|
|
||||||
|
|
||||||
|
def on_onboard(api, data=None):
|
||||||
|
username_file = identifyhome.identify_home() + f'plugins/{plugin_name}/usernames.dat'
|
||||||
|
with open(username_file, 'r') as usernames:
|
||||||
|
username_and_keys = usernames.readlines()
|
||||||
|
|
||||||
|
for entry in username_and_keys:
|
||||||
|
username, key = entry.split(',')
|
||||||
|
username = username.strip()
|
||||||
|
key = key.strip()
|
||||||
|
user = contactmanager.ContactManager(key, saveUser=True)
|
||||||
|
user.set_info('name', username)
|
||||||
|
|
||||||
|
|
||||||
|
|
1
static-data/default-plugins/usernames/usernames.dat
Normal file
1
static-data/default-plugins/usernames/usernames.dat
Normal file
@ -0,0 +1 @@
|
|||||||
|
Kevin Froman,GM3E4VCUNLF5F7Y64STD2HEURG45U3NYPLBZBT3Z6YWOALJHZPPQ
|
Loading…
Reference in New Issue
Block a user