Skip to content

Commit

Permalink
Add community id tag to event
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed May 11, 2024
1 parent e8f0db9 commit 3374543
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
17 changes: 8 additions & 9 deletions bot/modules/nostr/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { toKebabCase } = require('../../../util');
/// the event kind must be between 30000 and 39999
const kind = 38383;

const orderToTags = order => {
const orderToTags = async order => {
const expiration =
Math.floor(Date.now() / 1000) +
parseInt(process.env.ORDER_PUBLISHED_EXPIRATION_WINDOW);
Expand All @@ -24,6 +24,12 @@ const orderToTags = order => {
tags.push(['y', 'lnp2pbot']);
tags.push(['z', 'order']);
tags.push(['expiration', expiration.toString()]);
if (order.community_id) {
const community = await Community.findById(order.community_id);
if (community.public) {
tags.push(['community_id', order.community_id]);
}
}

return tags;
};
Expand All @@ -32,7 +38,7 @@ exports.createOrderEvent = async order => {
const myPrivKey = Config.getPrivateKey();

const created_at = Math.floor(Date.now() / 1000);
const tags = orderToTags(order);
const tags = await orderToTags(order);

const event = finalizeEvent(
{
Expand All @@ -44,13 +50,6 @@ exports.createOrderEvent = async order => {
myPrivKey
);

if (order.community_id) {
const community = await Community.findById(order.community_id);
if (community.public) {
event.tags.push(['community_id', order.community_id]);
}
}

const ok = verifyEvent(event);
if (!ok) {
console.log('Event not verified');
Expand Down
1 change: 0 additions & 1 deletion lnurl/lnurl-pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const existLightningAddress = async address => {

return true;
} catch (error) {
logger.info(`The lightning address ${address} does not exist`);
return false;
}
};
Expand Down

0 comments on commit 3374543

Please # to comment.