2018-07-16 07:40:58 +00:00
|
|
|
'''
|
2019-06-20 07:59:32 +00:00
|
|
|
Onionr - Private P2P Communication
|
2018-07-16 07:40:58 +00:00
|
|
|
|
|
|
|
This default plugin handles private messages in an email like fashion
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
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/>.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Imports some useful libraries
|
2019-03-06 22:39:46 +00:00
|
|
|
import logger, config, threading, time, datetime
|
2018-07-16 07:40:58 +00:00
|
|
|
from onionrblockapi import Block
|
2019-02-17 20:21:03 +00:00
|
|
|
import onionrexceptions
|
|
|
|
from onionrusers import onionrusers
|
2019-06-26 00:15:04 +00:00
|
|
|
from onionrutils import stringvalidators, escapeansi, bytesconverter
|
2019-02-08 18:53:28 +00:00
|
|
|
import locale, sys, os, json
|
2018-11-03 03:24:14 +00:00
|
|
|
|
2018-08-17 21:50:16 +00:00
|
|
|
locale.setlocale(locale.LC_ALL, '')
|
2018-07-16 07:40:58 +00:00
|
|
|
|
2019-03-02 06:22:59 +00:00
|
|
|
plugin_name = 'pms'
|
|
|
|
PLUGIN_VERSION = '0.0.1'
|
|
|
|
|
2018-11-03 03:24:14 +00:00
|
|
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
2019-03-02 19:17:18 +00:00
|
|
|
import sentboxdb, mailapi, loadinbox # import after path insert
|
|
|
|
flask_blueprint = mailapi.flask_blueprint
|
2018-07-16 07:40:58 +00:00
|
|
|
|
2019-03-02 06:22:59 +00:00
|
|
|
def add_deleted(keyStore, bHash):
|
|
|
|
existing = keyStore.get('deleted_mail')
|
|
|
|
if existing is None:
|
|
|
|
existing = []
|
|
|
|
else:
|
|
|
|
if bHash in existing:
|
|
|
|
return
|
|
|
|
keyStore.put('deleted_mail', existing.append(bHash))
|
|
|
|
|
2019-02-10 18:43:45 +00:00
|
|
|
def on_insertblock(api, data={}):
|
2019-02-11 22:36:43 +00:00
|
|
|
meta = json.loads(data['meta'])
|
2019-06-16 22:34:43 +00:00
|
|
|
if meta['type'] == 'pm':
|
2019-07-24 18:23:31 +00:00
|
|
|
sentboxTools = sentboxdb.SentBox()
|
2019-06-16 22:34:43 +00:00
|
|
|
sentboxTools.addToSent(data['hash'], data['peer'], data['content'], meta['subject'])
|
2019-02-10 18:43:45 +00:00
|
|
|
|
2018-07-16 07:40:58 +00:00
|
|
|
def on_init(api, data = None):
|
|
|
|
'''
|
|
|
|
This event is called after Onionr is initialized, but before the command
|
|
|
|
inputted is executed. Could be called when daemon is starting or when
|
|
|
|
just the client is running.
|
|
|
|
'''
|
|
|
|
|
|
|
|
pluginapi = api
|
2019-07-21 00:29:08 +00:00
|
|
|
|
2018-11-11 03:25:40 +00:00
|
|
|
return
|