<commit_before>package com.humbughq.android;

import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.text.TextUtils;

public class Message {
    public static final int STREAM_MESSAGE = 1;
    public static final int HUDDLE_MESSAGE = 2;
    public static final int PERSONAL_MESSAGE = 3;

    private String sender;
    private int type;
    private String content;
    private String subject;
    private String senderEmail;
    private Date timestamp;
    private String[] recipients;
    private int id;
    private String your_email;

    public Message(HumbugActivity context, JSONObject message)
            throws JSONException {
        this.your_email = context.email;
        this.populate(message);
    }

    public Message(JSONObject message) throws JSONException {
        this.populate(message);
    }

    public void populate(JSONObject message) throws JSONException {
        this.setSender(message.getString("sender_full_name"));
        this.setSenderEmail(message.getString("sender_email"));
        if (message.getString("type").equals("stream")) {
            this.setType(Message.STREAM_MESSAGE);
            recipients = new String[1];
            recipients[0] = message.getString("display_recipient");
        } else if (message.getString("type").equals("huddle")) {
            this.setType(Message.HUDDLE_MESSAGE);
            JSONArray jsonRecipients = message
                    .getJSONArray("display_recipient");
            recipients = new String[jsonRecipients.length() - 1];

            for (int i = 0; i < jsonRecipients.length(); i++) {
                if (!jsonRecipients.getJSONObject(i).getString("email")
                        .equals(this.your_email)) {
                    recipients[i] = jsonRecipients.getJSONObject(i).getString(
                            "full_name");
                }
            }
        } else if (message.getString("type").equals("personal")) {
            this.setType(Message.PERSONAL_MESSAGE);
            recipients = new String[1];
            recipients[0] = message.getJSONObject("display_recipient")
                    .getString("short_name");
        }
        this.setContent(message.getString("content"));
        if (this.getType() == Message.STREAM_MESSAGE) {
            this.setSubject(message.getString("subject"));
        } else {
            this.setSubject(null);
        }<commit_msg>Fix a crasher off-by-one and use full name instead of short for personals.<commit_after>package com.humbughq.android;

import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.text.TextUtils;

public class Message {
    public static final int STREAM_MESSAGE = 1;
    public static final int HUDDLE_MESSAGE = 2;
    public static final int PERSONAL_MESSAGE = 3;

    private String sender;
    private int type;
    private String content;
    private String subject;
    private String senderEmail;
    private Date timestamp;
    private String[] recipients;
    private int id;
    private String your_email;

    public Message(HumbugActivity context, JSONObject message)
            throws JSONException {
        this.your_email = context.email;
        this.populate(message);
    }

    public Message(JSONObject message) throws JSONException {
        this.populate(message);
    }

    public void populate(JSONObject message) throws JSONException {
        this.setSender(message.getString("sender_full_name"));
        this.setSenderEmail(message.getString("sender_email"));
        if (message.getString("type").equals("stream")) {
            this.setType(Message.STREAM_MESSAGE);
            recipients = new String[1];
            recipients[0] = message.getString("display_recipient");
        } else if (message.getString("type").equals("huddle")) {
            this.setType(Message.HUDDLE_MESSAGE);
            JSONArray jsonRecipients = message
                    .getJSONArray("display_recipient");
            recipients = new String[jsonRecipients.length() - 1];

            for (int i = 0; i < jsonRecipients.length() - 1; i++) {
                if (!jsonRecipients.getJSONObject(i).getString("email")
                        .equals(this.your_email)) {
                    recipients[i] = jsonRecipients.getJSONObject(i).getString(
                            "full_name");
                }
            }
        } else if (message.getString("type").equals("personal")) {
            this.setType(Message.PERSONAL_MESSAGE);
            recipients = new String[1];
            recipients[0] = message.getJSONObject("display_recipient")
                    .getString("full_name");
        }
        this.setContent(message.getString("content"));
        if (this.getType() == Message.STREAM_MESSAGE) {
            this.setSubject(message.getString("subject"));
        } else {
            this.setSubject(null);
        }
{'fraction_non_alphanumeric': 0.10539018503620273, 'fraction_numerical': 0.003821399839098954, 'mean_word_length': 2.441522491349481, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '806381', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1285, 'n_words': 281}