package com.okithaki.autoapp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import org.json.JSONObject;

/** Stores isolated neighborhood status/messages in the encrypted professional notification center. */
public final class NeighborhoodEventReceiver extends BroadcastReceiver {
    public static final String ACTION_EVENT="com.okithaki.autoapp.NEIGHBORHOOD_EVENT_V249530";
    @Override public void onReceive(Context context,Intent intent){
        if(context==null||intent==null||!ACTION_EVENT.equals(intent.getAction()))return;
        try{
            String eventId=intent.getStringExtra("event_id");if(eventId==null||eventId.trim().isEmpty())eventId="neighborhood_"+System.currentTimeMillis();
            JSONObject item=new JSONObject();item.put("id",eventId);item.put("notification_key",eventId);item.put("source","other");item.put("package_name",context.getPackageName());item.put("app_label","OK ITHAKI · Γειτονιά & Ραντάρ");
            item.put("title",String.valueOf(intent.getStringExtra("title")));item.put("body",String.valueOf(intent.getStringExtra("body")));item.put("created_at",intent.getLongExtra("created_at",System.currentTimeMillis()));
            item.put("unread",true);item.put("important",intent.getBooleanExtra("important",false));item.put("archived",false);item.put("item_type","neighborhood_event");item.put("local_only",true);
            ExternalMessageStoreV249477.put(context,item);
        }catch(Exception ignored){}
    }
}
