إذا كنت تدفع، نعم
هذا مكون إضافي مستقل، والدعم ليس مجانيًا ولا أقدم أي ضمانات - أنت تستخدمه على مسؤوليتك الخاصة.
كان بإمكاني بسهولة عدم مشاركة ذلك على الإطلاق، في أي مكان.
4 إعجابات
تم دمج هذا الآن، شكرًا مرة أخرى للداعمين @祁同伟 و @nathank
main ← automated_ip_based_user_location_determination
merged 09:02PM - 31 Jan 26 UTC
## IP‑based User Location (MaxMind → GeoNames)
### What this adds
- Auto… matically determines a user’s location from their IP after post creation.
- Uses **MaxMind (DiscourseIpInfo)** for identity + GeoNames for canonical lat/lon.
- Stores exactly **one granularity level** per user (`country` / `province` / `city`) in `UserCustomField`
`geo_location`.
- Ensures lat/lon match the chosen granularity (privacy‑correct coordinates).
- Caches GeoNames lookups by `geoname_id` (no extra gems; uses `FinalDestination::HTTP`).
---
## Prerequisites (official accounts)
You must have valid accounts and credentials from:
- **MaxMind GeoLite2**
Sign up and obtain an Account ID + License Key:
https://www.maxmind.com/en/geolite2/signup
- **GeoNames**
Create a username for the GeoNames API and **enable Web Services** in your GeoNames account settings:
https://www.geonames.org/login
---
## Required Configuration
**Env vars (MaxMind) for `app.yml`**
- `DISCOURSE_MAXMIND_ACCOUNT_ID`
- `DISCOURSE_MAXMIND_LICENSE_KEY`
**Site settings**
- `location_geonames_username` (GeoNames username)
**Dev note (MaxMind DBs)**
- In development, ensure the MaxMind DBs are downloaded:
DISCOURSE_MAXMIND_ACCOUNT_ID=... DISCOURSE_MAXMIND_LICENSE_KEY=... bundle exec rake maxminddb:get
Restart web/sidekiq afterward so `DiscourseIpInfo` reloads the DBs.
---
## Settings
| Setting | Default | Description |
|---|---:|---|
| `location_ip_granularity` | `city` | Controls stored level: `country`, `province` (admin1), `county` (admin2), or `city`. |
| `location_geonames_username` | `""` | GeoNames username for `getJSON` requests. Acts as a feature flag (blank => skip). |
| `location_ip_lookup_cooldown_days` | `1` | Per‑user cooldown between IP lookups (0 disables cooldown). |
| `locations_skip_ip_based_location_update_if_existing` | `true` | Skip IP lookup when existing `geo_location` already has **lat + lon**. |
| `location_ip_auto_lookup_enabled` | `false` | Auto‑enqueue IP lookups on post creation. Rake task still works when off. |
---
## Flow
- `post_created` → enqueue `Jobs::Locations::IpLocationLookup` with user ID + IP.
- Job:
- Guards: plugin enabled, users map enabled, GeoNames username present, MaxMind env vars present, cooldown
OK, and optional “existing location” check.
- Uses `DiscourseIpInfo.get(ip)` to get `geoname_ids`.
- Resolves GeoNames IDs, picks feature by granularity (`country` / `province` / `county` / `city`), builds
`geo_location`.
- Saves `geo_location` to user custom field + updates `locations_user` table.
---
## Job + Hook
**Hook**
- `post_created` now enqueues `Jobs::Locations::IpLocationLookup`
- In development, IP is overridden to a fixed test IP (`2.139.231.7`) to ensure resolvable data.
**Job**
- `Jobs::Locations::IpLocationLookup` (new, in `app/jobs/regular/locations/ip_location_lookup.rb`)
- Logs key steps, skips when prerequisites are missing.
- Writes `geo_location` only when successfully built.
---
## GeoNames Helpers
New modules in `lib/locations/`:
- `GeoNamesClient`
- Calls `https://secure.geonames.org/getJSON` via `FinalDestination::HTTP`.
- Normalizes `geoname_id`, `fcl`, `fcode`, `lat`, `lon`, etc.
- Caches only successful lookups (avoids caching nil).
- `GeoNamesGranularityPicker`
- Selects best `PCLI` / `ADM1` / `PPL*` by desired granularity.
- `GeoLocationBuilder`
- Builds `geo_location` hash with correct `lat/lon`, `state`/`city` based on granularity.
---
## Rake Task
New rake task in `lib/tasks/locations.rake`:
**Task**
rake locations:enqueue_user_ip_location_lookups[username_pattern,pattern_type,delay]
**Behavior**
- Iterates users and enqueues the IP lookup job using `user.ip_address`.
- Progress is based on **matched population** (not total users).
- Skips enqueue when IP is blank.
**Options**
- `username_pattern` (optional): filter users by username.
- `pattern_type`: `string` (default substring match) or `regex`.
- `delay`: seconds between enqueues (float, default `0`).
**Help**
rake locations:enqueue_user_ip_location_lookups:help
تفاصيل شاملة حول طلب السحب (PR).
@Roi ألاحظ أنك لا تدفع مقابل الدعم - ومع ذلك، أعتقد أنني ربما قمت بتحسين الكود في طلب السحب هذا، يرجى تجربة هذا السكريبت الذي نشرته مرة أخرى. إذا كنت بحاجة إليّ لإلقاء نظرة فاحصة، يمكنك توظيفي.
5 إعجابات
Roi
31 يناير 2026، 10:11م
1215
@merefield ليس بعد.
لقد تحققت للتو، وظل الإدخال السيئ موجودًا مع الإصدار الجديد أيضًا.
ولكن بما أنه كان مستخدمًا واحدًا فقط، فقد تحققت يدويًا وكان لديه مدينة في حقل الموقع “العادي” وأعدت إنشاء حقل الموقع بهذه المعلومات. الآن الاستعلام فارغ.
إعجابَين (2)
مرحباً، لقد نشرت تقريراً عن خطأ في مكان آخر وتمت إعادة توجيهي لإعادة نشره في هذا الموضوع.
اتضح أنه إذا قمت بتمكين المواقع لفئة ما وتعيين العرض الافتراضي للفئة على الخريطة، فإن الانتقال إلى تلك الفئة يؤدي إلى تعطل.
إليك بعض لقطات الشاشة (اعذروا الترجمة المحلية، الكلمات تعني “المظهر: قائمة المواضيع الافتراضية: ساخن، الأحدث، الأعلى، الخريطة”):
يبدو أن المكون الإضافي يصل إلى siteSettings بافتراض أنه مُعرَّف عندما لا يكون كذلك.
تقرير الخطأ الأصلي:
Support
Discourse Locations
Environment Discourse Version: v2026.2.0-latest +15 Plugin Commit: c1547ead Steps to Reproduce When using Locations plugin if I check Allow locations to be added to topics in this category and then try to set the map tab as the default view for...
Reading time: 1 mins 🕑
Likes: 1 ❤
إعجاب واحد (1)
شكرًا لك، إذا كان هذا الأمر مهمًا بما يكفي بالنسبة لك، يمكنك توظيفي لإصلاحه. نرحب بطلبات السحب (PR).
إعجاب واحد (1)
祁同伟
9 فبراير 2026، 10:52ص
1218
كيف يمكنني إخفاء معلومات الموقع من صفوف المواضيع في قائمة المواضيع؟
gilles
24 فبراير 2026، 6:50م
1221
لدي مشكلة في العرض منذ تحديث ديسكورس.
أنا على الإصدار 2026.2.0 الأحدث
إليك ما لدي
ربما تكون هناك طريقة لتصحيح ذلك باستخدام CSS
شكراً لك
إعجاب واحد (1)
Canapin
(Coin-coin le Canapin)
25 فبراير 2026، 6:46م
1223
نظرت بدافع الفضول. يبدو أن المواقع موجودة داخل زر، والذي تغير تصميمه (CSS) في سمة “foundation” الحديثة ويقيد المحتوى.
قد يكون هناك عدم توافق مستقبلي بين المواقع وهذه السمة، لكن الأخيرة لا تزال تجريبية، لذا نحتاج إلى انتظار الإصدار الرسمي ورؤية كيف ستسير الأمور
4 إعجابات
merefield
(Robert)
26 فبراير 2026، 2:29م
1224
إصدار صيانة:
main ← maintenance_release
merged 11:09PM - 25 Feb 26 UTC
## New Features
- Added a new enum setting: location_ip_auto_lookup_mode wi… th options:
- disabled
- posting
- login_and_posting
- Wired automatic IP-based location lookup into login flow (on(:user_logged_in)) when mode is login_and_posting.
- Added helper methods in plugin.rb to centralize IP auto-lookup mode/eligibility checks and enqueue behavior.
## Fixes
- Fixed composer default location initialization so user geo location is correctly prefilled when location_topic_default = user.
- Fixed category default-map rendering regression:
- category routes now render the map template safely when filter resolves to map
- avoids blank page / broken SPA behavior when category default view is map
- Fixed category map data loading by passing category context into the map template/component.
- Fixed map fallback fetch path to absolute /map.json to avoid route-relative request issues.
- Standardized users map route to users-map and removed legacy users_map usage paths.
## Configuration
- Introduced location_ip_auto_lookup_mode in config/settings.yml.
- Bumped plugin version to 7.1.6.
- Synced plugin JS devDependencies/config with core lint/tooling expectations.
## Code Formatting
- Migrated/modernized frontend code to satisfy current core lint rules:
- import path updates (discourse-i18n, moved package paths, etc.)
- removed deprecated patterns and jQuery usage
- template strict-mode migrations where required
- formatter/lint compliance cleanup across JS/GJS/HBS
- Updated prettier handling for vendored Leaflet assets to keep CI formatting checks clean.
## New Tests
- Added system spec: spec/system/composer_default_location_spec.rb
Validates composer initializes location from user location under the "user" default setting.
- Added system spec: spec/system/category_default_map_view_spec.rb
Validates category default map view renders map container without route error.
- Added request spec: spec/requests/users_map_controller_spec.rb
Covers canonical /locations/users-map route behavior.
- Extended request coverage for IP lookup posting/login mode behavior.
- Updated QUnit acceptance tests to assert intended behavior with stricter assertions and stable selectors.
تلاه إصلاح:
main ← copilot/fix-35533304-102999061-d25577a9-2d35-4b64-9e45-583c49295ad7
merged 02:05PM - 26 Feb 26 UTC
- [x] Analyze root cause: missing `.replace-location` CSS wrapper in both user c… ard connector and profile component templates
- [x] Fix `components/replace-location.gjs`: add `.replace-location` wrapper and update `showUserLocation` to use `model.geo_location`
- [x] Fix `connectors/user-card-location-and-website/replace-location.gjs`: add `.replace-location` wrapper
- [x] Add system tests for profile geo location visibility, native location hiding, website display, and user card location display
- [x] Bump patch version to 7.1.7
- [x] Fix CI: use `fab!(:user_with_location, :user)` shorthand (Rubocop Discourse/FabricatorShorthand)
- [x] Fix failing system test: replace fragile CSS-visibility check with content-based check
- [x] Fix test setup error: use `user_profile.update!(location: ...)` instead of `user.update!(location: ...)` — location is on UserProfile not User
- [x] Align user card and profile system tests: add "hides native location" and "shows website" scenarios to user card describe block, matching the full scope of the profile tests (selector differences only reflect the different component markup)
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Locations are not showing on profile and user card</issue_title>
> <issue_description>Since merefield/discourse-locations#155 locations are not showing on user card and profile page like they did before.
>
> The code should be hiding core location profile information but showing website.
>
> In the old code this was handled well, but seems have been lost during maintenance work.
>
> Check code prior to merefield/discourse-locations#155 to confirm how it should work.
>
> We should add system tests to ensure visibility of geo location and that we are hiding standard profile location field whilst exposing website from profile if any. </issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
- Fixes merefield/discourse-locations#156
---
✨ Let Copilot coding agent [set things up for you](https://github.com/merefield/discourse-locations/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
أبرز الميزات تشمل:
يمكنك الآن تحديث موقع الأشخاص تلقائيًا عند تسجيل الدخول (وليس فقط عند النشر) (@祁同伟 )
يتم التحكم فيه بواسطة الإعداد الجديد افتراضيًا إيقاف التشغيل - لذا إذا كنت تستخدم هذه الميزة، قم بتعيين تفضيلك الآن أو سيتوقف “المواقع” عن تحديث مواقع المستخدمين تمامًا - ضروري لأن نمط الإعداد قد تم تغييره لاستيعاب الميزة الجديدة.
يمكن الآن تحديد الخريطة مرة أخرى كعرض افتراضي للفئة (عبر إعدادات الفئة) (@Quacken )
يعمل تحديد الموقع الافتراضي للموضوع من موقع المستخدم مرة أخرى. (@祁同伟 )
بالإضافة إلى ألف تحديث ليتوافق مع أحدث قواعد التدقيق اللغوي.
9 إعجابات
pomodoren
(pomodoren)
26 فبراير 2026، 4:13م
1225
هل هناك أي فرصة للحصول على صفحة لموقع المستخدمين لكل مجموعة على وجه التحديد؟
لذا عمليًا يمكنني تقديم قائمة بأسماء المجموعات، ولكل منها، إنشاء خريطة للمستخدمين. في حالة الاستخدام الخاصة بنا على سبيل المثال، كنا نفكر في رسم خرائط للمستخدمين والمنظمات غير الحكومية و/أو الشركات بشكل منفصل.
أعني، يمكن للمرء دائمًا وضع “ngo_” قبل الاسم/اسم المستخدم والتصفية حسب ذلك، ولكن هذا ليس لطيفًا حقًا
4 إعجابات
merefield
(Robert)
26 فبراير 2026، 6:57م
1226
إذا كنت ترغب في تقديم بعض الرعاية الاسمية، بالتأكيد سأدعم ذلك - أرسل لي رسالة خاصة إذا كانت لديك ميزانية.
6 إعجابات
merefield
(Robert)
27 فبراير 2026، 11:54ص
1227
حسنًا، سأجعل هذا جهد تمويل جماعي
إذا رأيت زيادة في الرعاية الشهرية الحالية من المجتمع بما لا يقل عن 37 دولارًا (أنا حاليًا أرعاني 43 دولارًا شهريًا من قبل رعاتي الكرماء الحاليين)، سأضيف ما يلي:
تحسينات خريطة المستخدم:
تصفية المجموعة على الخريطة
للمستخدمين المسجلين فقط، قائمة المجموعة مرئية على الأقل لجميع المستخدمين المسجلين
القدرة على الربط بالخريطة لمجموعة مستخدمين محددة (نفس الحد على اختيار المجموعات)
تصفية لعدد الحد الأقصى للمستخدمين المعروضين (إعطاء الأولوية لآخر ظهور) - مكسب في الأداء لخريطة المستخدم إذا كان لديك الكثير من المستخدمين الذين لا يزورون الموقع بعد الآن ويفضلون المستخدمين النشطين فقط.
تطبيق إعدادات عرض الخريطة الافتراضية التي تنطبق حاليًا فقط على خريطة الموضوع - بحيث تعرض دائمًا منطقة اهتمامك.
رعاية عمل شهرية إضافية واحدة (>= 40 دولارًا) ستحسم الأمر على الفور (مستوى الفضة - SILVER tier)
ارعني هنا:
https://github.com/sponsors/merefield
لاحظ المكافآت للمستويات الأعلى.
6 إعجابات
nathank
(Nathan Kershaw)
6 مارس 2026، 4:53ص
1228
أحب هذه المبادرة (وعملك الجيد)؛ لقد قمت بإضافة تبرع شهري.
وهذه الميزات الثلاث ستكون مفيدة جدًا!
3 إعجابات
أُقدّر لك ذلك يا @nathank ، خاصة وأنك ساهمت أيضاً في المبادرة الأخيرة !
الآن أصبح لدينا فجوة شهرية قدرها 34 دولارًا، تقدم!
إعجابَين (2)
سأقبل أيضًا رعاية لمرة واحدة من فرد مقابل 150 دولارًا
لقد تلقيت مساهمة لمرة واحدة بقيمة 50 دولارًا (شكرًا لك!)، لذا سأخفض هذا الهدف إلى 100 دولار
7 إعجابات
مرحباً، كيف يمكنني معرفة ما إذا كان إصداري هو الأحدث بما أن مستودع غيت هب (github repo) لا يستخدم أي وسم (tag) أو إصدار (release)؟