From eb997ae9e3381f9f585c991ef8dc7ae81e348128 Mon Sep 17 00:00:00 2001
From: 23rd <23rd@vivaldi.net>
Date: Thu, 20 Jun 2024 06:00:02 +0300
Subject: [PATCH] Added initial implementation of filter for MTP updates.

---
 Telegram/CMakeLists.txt                       |  1 +
 Telegram/SourceFiles/api/api_filter_updates.h | 27 +++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 Telegram/SourceFiles/api/api_filter_updates.h

diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt
index 686bb93be..fc0f622fc 100644
--- a/Telegram/CMakeLists.txt
+++ b/Telegram/CMakeLists.txt
@@ -126,6 +126,7 @@ PRIVATE
     api/api_earn.h
     api/api_editing.cpp
     api/api_editing.h
+    api/api_filter_updates.h
     api/api_global_privacy.cpp
     api/api_global_privacy.h
     api/api_hash.cpp
diff --git a/Telegram/SourceFiles/api/api_filter_updates.h b/Telegram/SourceFiles/api/api_filter_updates.h
new file mode 100644
index 000000000..0126d3736
--- /dev/null
+++ b/Telegram/SourceFiles/api/api_filter_updates.h
@@ -0,0 +1,27 @@
+/*
+This file is part of Telegram Desktop,
+the official desktop application for the Telegram messaging service.
+
+For license and copyright information please follow this link:
+https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+*/
+#pragma once
+
+namespace Api {
+
+template <typename Type>
+void PerformForUpdate(
+		const MTPUpdates &updates,
+		Fn<void(const Type &)> callback) {
+	updates.match([&](const MTPDupdates &updates) {
+		for (const auto &update : updates.vupdates().v) {
+			update.match([&](const Type &d) {
+				callback(d);
+			}, [](const auto &) {
+			});
+		}
+	}, [](const auto &) {
+	});
+}
+
+} // namespace Api