private void LoadSettings() { // Debug: MODEL.DisableTcpTimeout = Settings.GetSettingBoolean(SettingsConsts.DEBUG_DISABLE_TCP_TIMEOUT); MODEL.DisableTlsTimeout = Settings.GetSettingBoolean(SettingsConsts.DEBUG_DISABLE_TLS_TIMEOUT); // Spam: MODEL.SpamRegex = Settings.GetSettingString(SettingsConsts.SPAM_REGEX, SpamHelper.DEFAULT_SPAM_REGEX); MODEL.SpamDetectionNewChatsOnly = !Settings.GetSettingBoolean(SettingsConsts.SPAM_DETECTION_FOR_ALL_CHAT_MESSAGES); MODEL.SpamDetectionEnabled = Settings.GetSettingBoolean(SettingsConsts.SPAM_DETECTION_ENABLED); // Device ID: MODEL.DeviceID = SharedUtils.GetUniqueDeviceId(); MODEL.DeviceNonce = CryptoUtils.byteArrayToHexString(SharedUtils.GetDeviceNonce()); StringBuilder accountIdsSb = new StringBuilder(); foreach (ClientConnectionHandler c in ConnectionHandler.INSTANCE.GetClients()) { accountIdsSb.Append(c.client.dbAccount.bareJid); accountIdsSb.Append(" ➔ "); accountIdsSb.Append(Push.Classes.Utils.ToAccountId(c.client.dbAccount.bareJid)); accountIdsSb.Append('\n'); } MODEL.AccountIds = accountIdsSb.ToString().Trim(); }
//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- #endregion //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- public override JObject ToJson() { JObject json = base.ToJson(); json["device_id"] = SharedUtils.GetUniqueDeviceId(); return(json); }
//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- #endregion //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- public override JObject ToJson() { JObject json = base.ToJson(); json["device_id"] = SharedUtils.GetUniqueDeviceId(); json["accounts"] = new JArray(from a in accounts select new JObject(new JProperty("account_id", a))); return(json); }
/// <summary> /// Generates a SHA256 hex string based on the given bare JID and the current device ID. /// </summary> /// <param name="bareJid">The bare JID (e.g. '*****@*****.**').</param> /// <returns>A SHA256 hex string.</returns> public static string ToAccountId(string bareJid) { string input = SharedUtils.GetUniqueDeviceId() + bareJid; byte[] result; using (SHA256 sha = SHA256.Create()) { result = sha.ComputeHash(Encoding.UTF8.GetBytes(input)); } return(CryptoUtils.byteArrayToHexString(result)); }
//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- #endregion //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- public override JObject ToJson() { JObject json = base.ToJson(); json["account"] = new JArray() { ["bare_jid"] = bareJid, ["device_id"] = SharedUtils.GetUniqueDeviceId(), ["channel_uri"] = channelUri }; return(json); }