Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
the-AjK committed Apr 9, 2018
2 parents 3aeb289 + 69d7ec3 commit 6f5d6a2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/telegram/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,20 @@ bot.mention(['@tables', '@table'], (ctx) => {
if (mention == 'table') {
//find user table and broadcast the message
for (let i = 0; i < orders.length; i++) {
let orderOwner = orders[i].owner._id.toString(),
user = ctx.session.user._id.toString();
if ( orderOwner === user) {
if (orders[i].owner._id.equals(ctx.session.user._id)) {
userHasOrdered = true;
const userTableName = orders[i].table.name;
for (let j = 0; j < orders.length; j++) {
if (orders[j].table.name == userTableName && orderOwner != user) {
if (!orders[j].owner._id.equals(ctx.session.user._id) &&
orders[j].table.name == userTableName) {
bot.telegram.sendMessage(orders[j].owner.telegram.id, message, {
parse_mode: "markdown"
});
counter += 1;
}
}
break;
}
break;
}
if (!userHasOrdered) {
userMessage = "You should place an order and choose your table!"
Expand Down

0 comments on commit 6f5d6a2

Please sign in to comment.