Skip to content

Commit

Permalink
Merge pull request sinamics#509 from sinamics/member-api
Browse files Browse the repository at this point in the history
Update the db member online status
  • Loading branch information
sinamics authored Aug 22, 2024
2 parents 052bbfa + 630cc45 commit be49590
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/server/api/services/memberService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ export const syncMemberPeersAndStatus = async (
// Update the connection status
updatedMember.conStatus = determineConnectionStatus(updatedMember);

// Check if the member is connected and has peers
const memberIsOnline =
Object.keys(updatedMember.peers).length > 0 && updatedMember.conStatus !== 0;

// Create the object with the data to be updated
const updateData: Partial<network_members> = {
id: updatedMember.id,
address: updatedMember.address,
online: memberIsOnline,
};

// Check if the member is connected and has peers, if so, update the lastSeen
const memberIsOnline =
Object.keys(updatedMember.peers).length > 0 && updatedMember.conStatus !== 0;

// add lastSeen to updateData if the member is connected
if (memberIsOnline) {
updateData.lastSeen = new Date();
Expand Down

0 comments on commit be49590

Please sign in to comment.