read web storage from config file
This commit is contained in:
parent
7f71b56988
commit
80059a7b91
14
session.py
14
session.py
|
@ -318,12 +318,16 @@ class Session(YowsupApp):
|
||||||
image.caption = ''
|
image.caption = ''
|
||||||
if image.isEncrypted():
|
if image.isEncrypted():
|
||||||
self.logger.debug('Received encrypted image message')
|
self.logger.debug('Received encrypted image message')
|
||||||
ipath = "uploads/" + str(image.timestamp) + image.getExtension()
|
if self.backend.specConf is not None and self.backend.specConf.__getitem__("service.web_directory") is not None and self.backend.specConf.__getitem__("service.web_url") is not None :
|
||||||
self.logger.debug('Received encrypted image message22')
|
ipath = "/" + str(image.timestamp) + image.getExtension()
|
||||||
|
|
||||||
|
with open(self.backend.specConf.__getitem__("service.web_directory") + ipath,"wb") as f:
|
||||||
|
f.write(image.getMediaContent())
|
||||||
|
url = self.backend.specConf.__getitem__("service.web_url") + ipath
|
||||||
|
else:
|
||||||
|
self.logger.warn('Received encrypted image: web storage not set in config!')
|
||||||
|
url = image.url
|
||||||
|
|
||||||
with open("/srv/www/htdocs/" + ipath,"wb") as f:
|
|
||||||
f.write(image.getMediaContent())
|
|
||||||
url = "http://www/" + ipath
|
|
||||||
else:
|
else:
|
||||||
url = image.url
|
url = image.url
|
||||||
if participant is not None: # Group message
|
if participant is not None: # Group message
|
||||||
|
|
|
@ -35,7 +35,7 @@ import threadutils
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
|
|
||||||
from Spectrum2.iochannel import IOChannel
|
from Spectrum2.iochannel import IOChannel
|
||||||
|
from config import SpectrumConfig
|
||||||
from whatsappbackend import WhatsAppBackend
|
from whatsappbackend import WhatsAppBackend
|
||||||
from yowsup.common import YowConstants
|
from yowsup.common import YowConstants
|
||||||
from yowsup.stacks import YowStack
|
from yowsup.stacks import YowStack
|
||||||
|
@ -64,6 +64,11 @@ logging.basicConfig(
|
||||||
level = logging.DEBUG if args.debug else logging.INFO
|
level = logging.DEBUG if args.debug else logging.INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if args.config is not None:
|
||||||
|
specConf = SpectrumConfig(args.config)
|
||||||
|
else:
|
||||||
|
specConf = None
|
||||||
|
|
||||||
# Handler
|
# Handler
|
||||||
def handleTransportData(data):
|
def handleTransportData(data):
|
||||||
try:
|
try:
|
||||||
|
@ -84,7 +89,7 @@ def connectionClosed():
|
||||||
# Main
|
# Main
|
||||||
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
||||||
|
|
||||||
plugin = WhatsAppBackend(io, args.j)
|
plugin = WhatsAppBackend(io, args.j, specConf)
|
||||||
|
|
||||||
plugin.handleBackendConfig({
|
plugin.handleBackendConfig({
|
||||||
'features': [
|
'features': [
|
||||||
|
|
|
@ -30,10 +30,11 @@ from registersession import RegisterSession
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
class WhatsAppBackend(SpectrumBackend):
|
class WhatsAppBackend(SpectrumBackend):
|
||||||
def __init__(self, io, spectrum_jid):
|
def __init__(self, io, spectrum_jida, specConf):
|
||||||
SpectrumBackend.__init__(self)
|
SpectrumBackend.__init__(self)
|
||||||
self.logger = logging.getLogger(self.__class__.__name__)
|
self.logger = logging.getLogger(self.__class__.__name__)
|
||||||
self.io = io
|
self.io = io
|
||||||
|
self.specConf = specConf
|
||||||
self.sessions = { }
|
self.sessions = { }
|
||||||
self.spectrum_jid = spectrum_jid
|
self.spectrum_jid = spectrum_jid
|
||||||
# Used to prevent duplicate messages
|
# Used to prevent duplicate messages
|
||||||
|
|
Loading…
Reference in a new issue