!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/note.picotech.app/public_html/src/models/   drwxr-xr-x
Free 25.88 GB of 117.98 GB (21.93%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     index.js (5.83 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
const { sequelize } = require('../config/database');
const User = require('./User');
const Meeting = require('./Meeting');
const Note = require('./Note');
const Recording = require('./Recording');
const AudioChunk = require('./AudioChunk');
const Transcript = require('./Transcript');
const Summary = require('./Summary');
const Label = require('./Label');
const Otp = require('./Otp');
const UserUploadLimit = require('./UserUploadLimit');
const ApiKey = require('./ApiKey');
const FailedLoginAttempt = require('./FailedLoginAttempt');
const DataDeletionRequest = require('./DataDeletionRequest');

// Define associations
const defineAssociations = () => {
  // User associations
  User.hasMany(Meeting, {
    foreignKey: 'user_id',
    as: 'meetings',
    onDelete: 'CASCADE',
  });

  User.hasMany(Note, {
    foreignKey: 'user_id',
    as: 'notes',
    onDelete: 'CASCADE',
  });

  User.hasMany(Label, {
    foreignKey: 'user_id',
    as: 'labels',
    onDelete: 'CASCADE',
  });

  // Meeting associations
  Meeting.belongsTo(User, {
    foreignKey: 'user_id',
    as: 'user',
  });

  Meeting.hasMany(Note, {
    foreignKey: 'meeting_id',
    as: 'notes',
    onDelete: 'CASCADE',
  });

  Meeting.hasMany(Recording, {
    foreignKey: 'meeting_id',
    as: 'recordings',
    onDelete: 'CASCADE',
  });

  Meeting.hasMany(Transcript, {
    foreignKey: 'meeting_id',
    as: 'transcripts',
    onDelete: 'CASCADE',
  });

  Meeting.hasOne(Summary, {
    foreignKey: 'meeting_id',
    as: 'summary',
    onDelete: 'CASCADE',
  });

  // Note associations
  Note.belongsTo(User, {
    foreignKey: 'user_id',
    as: 'user',
  });

  Note.belongsTo(Meeting, {
    foreignKey: 'meeting_id',
    as: 'meeting',
  });

  Note.belongsTo(User, {
    foreignKey: 'last_edited_by',
    as: 'lastEditor',
  });

  // Self-referencing association for note threading
  Note.belongsTo(Note, {
    foreignKey: 'parent_note_id',
    as: 'parentNote',
  });

  Note.hasMany(Note, {
    foreignKey: 'parent_note_id',
    as: 'replies',
  });

  // UserUploadLimit associations - commented out for now
  // User.hasOne(UserUploadLimit, {
  //   foreignKey: 'user_id',
  //   as: 'uploadLimits',
  //   onDelete: 'CASCADE',
  // });

  // UserUploadLimit.belongsTo(User, {
  //   foreignKey: 'user_id',
  //   as: 'user',
  // });

  // Recording associations
  Recording.belongsTo(Meeting, {
    foreignKey: 'meeting_id',
    as: 'meeting',
  });

  Recording.hasOne(Transcript, {
    foreignKey: 'recording_id',
    as: 'transcript',
    onDelete: 'CASCADE',
  });

  Recording.hasMany(AudioChunk, {
    foreignKey: 'recording_id',
    as: 'chunks',
    onDelete: 'CASCADE',
  });

  // AudioChunk associations
  AudioChunk.belongsTo(Recording, {
    foreignKey: 'recording_id',
    as: 'recording',
  });

  // Transcript associations
  Transcript.belongsTo(Recording, {
    foreignKey: 'recording_id',
    as: 'recording',
  });

  Transcript.belongsTo(Meeting, {
    foreignKey: 'meeting_id',
    as: 'meeting',
  });

  Transcript.belongsTo(User, {
    foreignKey: 'edited_by',
    as: 'editor',
  });

  // Summary associations
  Summary.belongsTo(Meeting, {
    foreignKey: 'meeting_id',
    as: 'meeting',
  });

  Summary.belongsTo(User, {
    foreignKey: 'edited_by',
    as: 'editor',
  });

  Summary.belongsTo(User, {
    foreignKey: 'approved_by',
    as: 'approver',
  });
};

// Initialize associations
defineAssociations();

// Sync database (create tables if they don't exist)
const syncDatabase = async (options = {}) => {
  try {
    await sequelize.sync(options);
    console.log('✅ Database synchronized successfully.');
  } catch (error) {
    console.error('❌ Error synchronizing database:', error);
    throw error;
  }
};

// Drop all tables (use with caution!)
const dropDatabase = async () => {
  try {
    await sequelize.drop();
    console.log('✅ Database dropped successfully.');
  } catch (error) {
    console.error('❌ Error dropping database:', error);
    throw error;
  }
};

// Create database with sample data
const seedDatabase = async () => {
  try {
    // Create a sample user
    const user = await User.create({
      email: 'demo@piconote.com',
      name: 'Demo User',
      password_hash: 'demo123', // Will be hashed by the model hook
      email_verified: true,
    });

    // Create a sample meeting
    const meeting = await Meeting.create({
      title: 'Weekly Team Standup',
      description: 'Weekly team sync to discuss progress and blockers',
      start_time: new Date(),
      user_id: user.id,
      attendees: ['Alice Johnson', 'Bob Smith', 'Carol Davis'],
      tags: ['weekly', 'standup', 'team'],
    });

    // Create sample notes
    await Note.create({
      meeting_id: meeting.id,
      user_id: user.id,
      title: 'Meeting Notes',
      content_blocks: [
        {
          id: '1',
          type: 'heading',
          content: 'Weekly Team Standup - ' + new Date().toLocaleDateString(),
        },
        {
          id: '2',
          type: 'text',
          content: 'Team discussed current sprint progress and upcoming deliverables.',
        },
        {
          id: '3',
          type: 'action_item',
          content: 'Alice to review the API documentation by Friday',
          metadata: { assignee: 'Alice Johnson', due_date: '2025-01-31' },
        },
      ],
      tags: ['standup', 'notes'],
      status: 'active',
    });

    console.log('✅ Database seeded with sample data.');
    console.log(`📧 Demo user created: ${user.email}`);
    console.log(`🏢 Demo meeting created: ${meeting.title}`);
  } catch (error) {
    console.error('❌ Error seeding database:', error);
    throw error;
  }
};

module.exports = {
  sequelize,
  User,
  Meeting,
  Note,
  Recording,
  AudioChunk,
  Transcript,
  Summary,
  Label,
  Otp,
  UserUploadLimit,
  ApiKey,
  FailedLoginAttempt,
  DataDeletionRequest,
  syncDatabase,
  dropDatabase,
  seedDatabase,
  defineAssociations,
};

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.003 ]--