Skip to content

feat: add reject_application() so business can formally decline applicants #3

Description

@JamesVictor-O

Background

The AdsBazaar business dashboard applicant review panel has two actions per applicant: Approve (maps to select_creator) and Reject. Currently only select_creator exists — there is no on-chain way to formally reject an applicant.

Without rejection, the contract cannot distinguish between "pending review" and "deliberately declined". This blocks the frontend from showing accurate application status to creators.

Signature

pub fn reject_application(env: Env, campaign_id: u64, business: Address, creator: Address) -> Result<(), Error>

Rules

  • Only the campaign's business address may call this
  • Campaign must be Open or Active
  • Application must exist and have status == Applied (cannot reject an already-selected creator via this path)
  • Sets application.status = ApplicationStatus::Rejected
  • Does not affect campaign status or budget

Implementation notes

pub fn reject_application(env: Env, campaign_id: u64, business: Address, creator: Address) -> Result<(), Error> {
    business.require_auth();
    let campaign = Self::campaign(env.clone(), campaign_id)?;
    if campaign.business != business {
        return Err(Error::NotCampaignOwner);
    }
    let mut application: Application = env
        .storage()
        .persistent()
        .get(&DataKey::Application(campaign_id, creator.clone()))
        .ok_or(Error::ApplicationNotFound)?;
    if application.status != ApplicationStatus::Applied {
        return Err(Error::ApplicationNotFound); // already actioned
    }
    application.status = ApplicationStatus::Rejected;
    env.storage().persistent().set(
        &DataKey::Application(campaign_id, creator.clone()),
        &application,
    );
    env.events().publish(
        (Symbol::new(&env, "application_rejected"), campaign_id),
        creator,
    );
    Ok(())
}

Files

  • src/lib.rs — add ApplicationStatus::Rejected variant and reject_application function
  • Update ApplicationStatus enum (it currently only has Applied, Selected, Rejected — confirm Rejected is present and exercised)

Acceptance criteria

  • reject_application is callable only by the campaign's business address
  • Returns Error::NotCampaignOwner for non-owner callers
  • Returns Error::ApplicationNotFound when application doesn't exist or is already actioned
  • Sets application status to Rejected
  • Emits application_rejected event with campaign_id and creator address
  • Test: apply → reject → assert status is Rejected
  • Test: apply → select → attempt reject → returns error (already actioned)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions