def sendMail(name, email, password): if email and password: msg = Message("Nucleo Medico", recipients=[email]) msg.html = """ <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr style="background-color: #2780E3;"> <td> <table> <tr> <td> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Wiki_Project_Med_Foundation_logo.svg/800px-Wiki_Project_Med_Foundation_logo.svg.png" alt="VaraS de Esculapio" width="42" style="padding: 5px;"> </td> <td style="vertical-align: middle; height: 42px;"> <span style="color:azure; padding: 5px;">Nucleo Medico</span> </td> </tr> </table> </td> </tr> <tr> <td align="center" style="background-color: #eeeeee;"> <table border="0" cellpadding="0" cellspacing="0" width="80%" style="margin: 15px; background-color: white; padding: 10px 15px;"> <tr> <td> <p>Hola, """ + name + """:</p> </td> </tr> <tr> <td style="color: #757575; padding: 0 10px;"> <p>Se te a invitado a colaborar con el doctor """ + session[ 'name'] + """, en su farmacia.</p> <p>Tu usuario es tu correo electronico. Su contraseña sera provisional solo para su primer ingreso, no la comparta con nadie, en ningun momento.</p> <p style="color: #01579b; padding-left: 15px;">""" + password + """</p> </td> </tr> <tr> <td style="color: #757575;"> <br> <br> <p style="font-size: x-small;">El contenido de este email es totalmente privado no se debe ser compartido con nadie en ningun momento.</p> </td> </table> </td> </tr> </table> """ try: mail.send(msg) except Exception as identifier: return str(identifier) return redirect(url_for('employees.employees'))
def test_on_envelope_message(self, mocker: MockerFixture) -> None: # Arrange channel = self.__get_target() message = Message(ContentTypes.PING, {}) spy = mocker.spy(channel, 'on_message') # Act channel.on_envelope(message.to_json()) # Assert spy.assert_called_once_with(message)
def message(id): auth_token = request.headers['Authorization'] authorized = User.is_authorized(auth_token) if authorized: user_id = User.decode(auth_token) data = json.loads(request.data) text = data['text'] Message.create(text, id, user_id) return Response(status=201, mimetype='application/json') else: return Response(status=401, smimetype='application/json')
def get_next_unprocessed_message(self, admin_login): mid = self.redis.srandmember(Set.UNPROCESSED_MESSAGES, 1) if not mid or not mid[0]: return mid = mid[0] message = Message.load(mid, self.redis) message_key = '%s:%s' % (Storage.MESSAGES, mid) author = self.redis.hget(message_key, 'author') pipe = self.redis.pipeline() pipe.srem(Set.UNPROCESSED_MESSAGES, mid) pipe.zrem('%s:%s' % (Set.WAIT_MODERATING_MESSAGES, author), mid) message.status = MessageStatus.MODERATING message.save(pipe) pipe.zadd('%s:%s' % (Set.MODERATING_MESSAGES, author), {mid: now()}) pipe.lpush( 'logs', '"%s" took message "%s" on moderation' % (admin_login, mid), ) pipe.execute() return message
def get_next_unprocessed_message(self, admin_login): mid = self.redis.srandmember(constants.SET_UNPROCESSED_MESSAGES, 1) if not mid or not mid[0]: return mid = mid[0] message_key = '%s:%s' % (constants.MESSAGES_STORAGE, mid) author = self.redis.hget(message_key, 'author') message = Message.load(mid, self.redis) p = self.redis.pipeline() # delete message from list of unprocessed messages p.srem(constants.SET_UNPROCESSED_MESSAGES, mid) # delete message from group 'created messages' p.zrem('%s:%s' % (constants.SS_WAIT_FOR_MODERATION_MESSAGES, author), mid) # update status of a message message.status = constants.STATUS_MESSAGE_ON_MODERATION message.save(p) # add message to group with messages 'on moderation' p.zadd('%s:%s' % (constants.SS_MESSAGES_ON_MODERATION, author), {mid: now()}) # write logs p.lpush(constants.LIST_ACTION_LOGS, '"%s" took message "%s" on moderation' % (admin_login, mid)) p.execute() return message
def enter(self): query = self.ask().get('query').lower() keys = {'%s:%s' % (constants.WORDS_STORAGE, word) for word in query.split()} results = self.redis.sinter(keys) messages = [Message.load(key, self.redis) for key in results] FoundMessagesViewerScene(query, messages).enter()
def enter(self): answers = self.ask() if not answers['confirm']: return self.session['chat'].publish_message( Message(author=self.session['me'].login, to=answers['to'], body=answers['body']))
def test_is_message_should_be_true(self): # Arrange envelope = Message('application/json', {'some': 'content'}) # Act result = Envelope.is_message(envelope) # Assert assert result is True
def perform_actions_as(self, user, delay): print('Hello, I\'m %s' % user.login) for _ in range(int(random() * 30)): time.sleep(random() * delay) if (random() < 0.4): print('💛 %s wants to read a message' % user.login) mid = self.redis.zpopmin( '%s:%s' % (constants.SS_INCOMING_MESSAGES, user.login)) if not mid or not mid[0]: print('But %s has not a new message' % user.login) continue mid = mid[0][0] msg = Message.load(mid, self.redis) self.chat.read_message(msg) else: to = USERS[math.floor(random() * len(USERS))] msg = Message(author=user.login, to=to, body=lorem.sentence()) print('💙 %s writes a message to %s ||| message text: %s' % (user.login, to, msg.body)) self.chat.publish_message(msg)
def contact(): form = ContactForm() if request.method == 'POST': if form.validate() == False: flash('Alle feltene må fylles ut.') return render_template('contact.html', form=form) else: msg = Message(form.subject.data, sender='*****@*****.**', recipients=['*****@*****.**']) msg.body = """ Fra: %s, %s; %s """ % (form.name.data, form.email.data, form.message.data) mail.send(msg) return render_template('contact.html', success=True) elif request.method == 'GET': return render_template('contact.html', form=form)
def enter(self): answers = self.ask() if not answers["confirm"]: return self.session["chat"].publish_message( Message( author=self.session["me"].login, receiver=answers["receiver"], body=answers["body"], ) )
def importFileContent(self, conversationList): if (self.debug == "DEBUG"): print("Parser:::Entered importFileContent()") for convo in conversationList: if convo.folderName == self.dirPath: for f in self.fileNames: filePath = "Data/messages/inbox/" + self.dirPath + "/" + f with open(filePath) as j: data = json.load(j) if (self.debug == "DEBUG"): print( "Parser:::importfileContent():::readingFile: ", filePath) #Import Participants ------------------------------------------------ for i in data['participants']: for person in i: exists = False for participant_obj in self.chatParticipants: if i[person] == participant_obj.name: exists = True if (exists == True): exists = False else: self.chatParticipants.append( Participant.Participant(i[person])) if (self.debug == "DEBUG"): print( "Parser::: importFileContent() ::: Import Participants ::: ", i[person]) #Import Messages ------------------------------------------------ for m in data['messages']: sender = "" timeStamp = 0 content = "" contentType = "" photo_uri = "" gifs_uri = "" sticker_uri = "" for msgData in m: if (msgData == "sender_name"): sender = m[msgData] if (msgData == "timestamp_ms"): timeStamp = m[msgData] if (msgData == "content"): content = m[msgData] if (msgData == "photos"): for photoData in m['photos']: photo_uri = photoData['uri'] if (msgData == "gifs"): for photoData in m['gifs']: gifs_uri = photoData['uri'] if (msgData == "sticker"): for photoData in m['sticker']: pass # sticker_uri = photoData['uri'] if (msgData == "type"): contentType = m[msgData] #Append to overall Message object array self.messages.append( Message.Message(sender, timeStamp, content, photo_uri, gifs_uri, sticker_uri)) #Check if sender is in participants list # Participants who have left the chat don't show up in the default participants existingNames = [] for participant_obj in self.chatParticipants: existingNames.append(participant_obj.name) if sender not in existingNames: self.chatParticipants.append( Participant.Participant(sender)) #Append to each participant's Participant object for participant_obj in self.chatParticipants: if participant_obj.name == sender: participant_obj.timeStamps.append( timeStamp) participant_obj.contentType.append( contentType) if (content not in self.avoid_messages): participant_obj.messages.append( content) if (photo_uri != ""): participant_obj.photosCount += 1 if (gifs_uri != ""): participant_obj.gifsCount += 1 if (sticker_uri != ""): participant_obj.stickersCount += 1 convo.participantList = self.chatParticipants convo.getMessageList = self.messages
def handle_message_created_as_worker(self, message): self.process_message_as_worker( Message.load(message['data'], self.redis))
def handle_message_created_as_worker(self, message): message_instance = Message.load(message["data"], self.redis) self.process_message_as_worker(message_instance)
def do_message(self, arg): scalp_ms = ms.Message() scalp_ms.get_message()
def read_message(self, mid): message = Message.load(mid, self.redis) pprint(message.to_dict()) if message.status != constants.STATUS_MESSAGE_READ: self.chat.read_message(message)
def read_message(self, mid): message = Message.load(mid, self.redis) pprint(message.to_dict()) if message.status != MessageStatus.READ: self.chat.read_message(message)