pyrogram why phone_number is "*********"? - get

get_chat_members(pyrogram) gives characters ********* instead of phone_numbers
"_": "User",
"id": ##########,
"is_self": true,
"is_contact": false,
"is_mutual_contact": false,
"is_deleted": false,
"is_bot": false,
"is_verified": false,
"is_restricted": false,
"is_scam": false,
"is_fake": false,
"is_support": false,
"is_premium": false,
"first_name": "#########",
"last_name": "###########",
"status": "UserStatus.OFFLINE",
"last_online_date": "2023-01-13 16:18:34",
"username": "###########",
"phone_number": "*********"

The phone_number field will be censored to protect the privacy, should the User object be printed or returned. If you want the actual number, access the value itself.
user = app.get_users(789456123)
print(user)
{
"_": "User",
"id": 789456123,
"phone_number": *********,
...
}
print(user.phone_number)
"49123456789"

Related

Pimcore: New product class not visible in e-commerce product list

Goal
Data objects of my data object class Product should be visible in the e-commerce Pimcore site.
Current Setup
Current Demo and Blue Print Application for Pimcore
I create a new data object class called Product. Parent PHP class is set to \App\Model\Product\AbstractProduct (Complete class definition export attached)
Created a new data object based on the Product class.
Result
The new product is not visible in the shop. There is no error shown up either.
What I also tried
Based on the Index Service documentation I manually updated the index, without any effect.
$ php bin/console ecommerce:indexservice:bootstrap --update-index
Processing 1 Product in segments of 50, batches of 50, 1 round, 1 batch in 1 process
1/1 [============================] 100% < 1 sec/< 1 sec 48.5 MiB
Processed 1 Product.
Attached complete class definition export
{
"id": "PROD",
"description": "",
"modificationDate": 1669880184,
"parentClass": "\\App\\Model\\Product\\AbstractProduct",
"implementsInterfaces": "",
"listingParentClass": "",
"useTraits": "",
"listingUseTraits": "",
"allowInherit": true,
"allowVariants": true,
"showVariants": true,
"layoutDefinitions": {
"name": "pimcore_root",
"type": null,
"region": null,
"title": null,
"width": 0,
"height": 0,
"collapsible": false,
"collapsed": false,
"bodyStyle": null,
"datatype": "layout",
"permissions": null,
"children": [
{
"name": "Layout",
"type": null,
"region": null,
"title": "",
"width": "",
"height": "",
"collapsible": false,
"collapsed": false,
"bodyStyle": "",
"datatype": "layout",
"permissions": null,
"children": [
{
"name": "Base Data",
"type": null,
"region": null,
"title": "Base Data",
"width": "",
"height": "",
"collapsible": false,
"collapsed": false,
"bodyStyle": "",
"datatype": "layout",
"permissions": null,
"children": [
{
"name": "productName",
"title": "Product Name",
"tooltip": "",
"mandatory": true,
"noteditable": false,
"index": true,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "input",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"width": "",
"defaultValue": null,
"columnLength": 190,
"regex": "",
"regexFlags": [],
"unique": true,
"showCharCount": false,
"defaultValueGenerator": ""
},
{
"name": "localizedfields",
"title": "",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": null,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "localizedfields",
"relationType": false,
"invisible": false,
"visibleGridView": true,
"visibleSearch": true,
"children": [
{
"name": "description",
"title": "Description",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "textarea",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"width": "",
"height": "",
"maxLength": null,
"showCharCount": false,
"excludeFromSearchIndex": false
},
{
"name": "packaging",
"title": "Packaging",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "input",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"width": "",
"defaultValue": null,
"columnLength": 190,
"regex": "",
"regexFlags": [],
"unique": false,
"showCharCount": false,
"defaultValueGenerator": ""
}
],
"region": null,
"layout": null,
"width": "",
"height": "",
"maxTabs": null,
"border": false,
"provideSplitView": false,
"tabPosition": null,
"hideLabelsWhenTabsReached": null,
"fieldDefinitionsCache": null,
"permissionView": null,
"permissionEdit": null,
"labelWidth": 0,
"labelAlign": "left"
},
{
"name": "image",
"title": "Image",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "image",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"width": "",
"height": "",
"uploadPath": ""
},
{
"name": "group",
"title": "Group",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "manyToOneRelation",
"relationType": true,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"classes": [
{
"classes": "ProductGroup"
}
],
"pathFormatterClass": "",
"width": "",
"assetUploadPath": "",
"objectsAllowed": true,
"assetsAllowed": false,
"assetTypes": [],
"documentsAllowed": false,
"documentTypes": []
},
{
"name": "categories",
"title": "Categories",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "manyToManyObjectRelation",
"relationType": true,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"classes": [
{
"classes": "Category"
}
],
"pathFormatterClass": "",
"width": "",
"height": "",
"maxItems": null,
"visibleFields": "id,fullpath,name",
"allowToCreateNewObject": false,
"optimizedAdminLoading": false,
"enableTextSelection": false,
"visibleFieldDefinitions": []
}
],
"locked": false,
"fieldtype": "panel",
"layout": null,
"border": false,
"icon": "",
"labelWidth": 0,
"labelAlign": "left"
},
{
"name": "Attributes",
"type": null,
"region": null,
"title": "Attributes",
"width": "",
"height": "",
"collapsible": false,
"collapsed": false,
"bodyStyle": "",
"datatype": "layout",
"permissions": null,
"children": [
{
"name": "attributes",
"title": "Attributes",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "objectbricks",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"allowedTypes": [
"EdgebandingAttributes"
],
"maxItems": null,
"border": false
},
{
"name": "saleInformation",
"title": "Sale Information",
"tooltip": "",
"mandatory": false,
"noteditable": false,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"fieldtype": "objectbricks",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false,
"allowedTypes": [
"SaleInformation"
],
"maxItems": null,
"border": false
}
],
"locked": false,
"fieldtype": "panel",
"layout": null,
"border": false,
"icon": "",
"labelWidth": 0,
"labelAlign": "left"
}
],
"locked": false,
"fieldtype": "tabpanel",
"border": false,
"tabPosition": null
}
],
"locked": false,
"fieldtype": "panel",
"layout": null,
"border": false,
"icon": null,
"labelWidth": 100,
"labelAlign": "left"
},
"icon": "",
"previewUrl": "",
"group": "Product Data",
"showAppLoggerTab": false,
"linkGeneratorReference": "",
"previewGeneratorReference": "",
"compositeIndices": [],
"generateTypeDeclarations": true,
"showFieldLookup": false,
"propertyVisibility": {
"grid": {
"id": true,
"key": false,
"path": true,
"published": true,
"modificationDate": true,
"creationDate": true
},
"search": {
"id": true,
"key": false,
"path": true,
"published": true,
"modificationDate": true,
"creationDate": true
}
},
"enableGridLocking": false
}
I finally got it to work (after my last answer which was supposed to be a comment, my bad :D )
did you check the following:
1 Class override
https://pimcore.com/docs/pimcore/current/Development_Documentation/Extending_Pimcore/Overriding_Models.html
in /config/ecommerce/base-ecommerce.yaml
pimcore:
models:
class_overrides:
Pimcore\Model\DataObject\YourClass: App\Model\Product\YourClass
make sure you clear the cache like in the documentation
./bin/console cache:clear --no-warmup && ./bin/console pimcore:cache:clear
2 Check all Car Class names in Model / Controller
For example:
src/controller/productController.php
src/Model/Adminstyle/Car --> to your Class
src/Model/Car --> to your Class
3 Make sure that saving a product of yours gets in the index
I saw that on saving the object in the backend, i got a log that the object was not indexed.
https://pimcore.com/docs/pimcore/current/Development_Documentation/E-Commerce_Framework/Index_Service/Product_Index_Configuration/Data_Architecture_and_Indexing_Process.html
I had some other issues which where 100% not meant to be fixed like i did. So try how far you come with this
edit: typo

Get all records that have an item in an array with certain email

I am trying to write a CosmosDB query to return all records in a table that have an item in the Users array that has an email of a certain value. Here is roughly what a full record looks like.
{
"year": "2022",
"id": "d992b109-d94a-4d75-9ebb-9ef4e5e851ae",
"partitionKey": "2022",
"LeagueName": "Hipster Kitties",
"Users": [
{
"Id": "eb71e719-4bc1-4f32-9767-e5dc20b2e63f",
"UserName": "fake#gmail.com",
"NormalizedUserName": "fake#gmail.com",
"Email": "fake#gmail.com",
"NormalizedEmail": "fake#gmail.com",
"EmailConfirmed": false,
"PhoneNumber": null,
"PhoneNumberConfirmed": false,
"TwoFactorEnabled": false,
"LockoutEnd": null,
"LockoutEnabled": true,
"AccessFailedCount": 0
},
{
"Id": "eb71e719-4bc1-4f32-9767-e5dc20sdfsdf",
"UserName": "fake2#gmail.com",
"NormalizedUserName": "fake2#gmail.com",
"Email": "fake2#gmail.com",
"NormalizedEmail": "fake2#gmail.com",
"EmailConfirmed": false,
"PhoneNumber": null,
"PhoneNumberConfirmed": false,
"TwoFactorEnabled": false,
"LockoutEnd": null,
"LockoutEnabled": true,
"AccessFailedCount": 0
}
],
"LeagueCreator": {
"Id": "eb71e719-4bc1-4f32-9767-e5dc20b2e63f",
"UserName": "fake#gmail.com",
"NormalizedUserName": "fake#gmail.com",
"Email": "fake#gmail.com",
"NormalizedEmail": "fake#gmail.com",
"EmailConfirmed": false,
"PhoneNumber": null,
"PhoneNumberConfirmed": false,
"TwoFactorEnabled": false,
"LockoutEnd": null,
"LockoutEnabled": true,
"AccessFailedCount": 0
},
"LeagueAdmins": [
{
"Id": "eb71e719-4bc1-4f32-9767-e5dc20b2e63f",
"UserName": "fake#gmail.com",
"NormalizedUserName": "fake#gmail.com",
"Email": "fake#gmail.com",
"NormalizedEmail": "fake#gmail.com",
"EmailConfirmed": false,
"PhoneNumber": null,
"PhoneNumberConfirmed": false,
"TwoFactorEnabled": false,
"LockoutEnd": null,
"LockoutEnabled": true,
"AccessFailedCount": 0
}
],
"IsPublic": false,
"Seasons": [],
"Type": 1,
"Settings": {
"TotalPicks": 6,
"KeyPicks": 1,
"KeyPickBonus": 1,
"WeekStartingMoney": 0,
"MinimumGamesToPick": 0
},
"_attachments": "attachments/",
"_ts": 1665116599
}
Here is the query I have so far which will get me the id's, but I can't get the full records.
SELECT c.id
FROM c
JOIN t in c.Users
WHERE t.Email = "eric.triebe#gmail.com"
If I execute the following query, I get a SQL syntax error.
SELECT *
FROM c
WHERE c.id IN (SELECT d.id
FROM d
JOIN t in d.Users
WHERE t.Email = "fake#gmail.com")
Message: {"errors":[{"severity":"Error","location":{"start":33,"end":39},"code":"SC1001","message":"Syntax error, incorrect syntax near 'SELECT'."}]} ActivityId: , Microsoft.Azure.Documents.Common/2.14.0
Worst case, I could get back these Id's and then run another query which would get all records with those Id's, but want to see if I can run it in one query instead of two.
You can't just SELECT *. You can specify individual properties though. For example:
SELECT c.id, c.LeagueName, t.UserName, t.Email
FROM c
JOIN t in c.Users
WHERE t.Email = "fake#gmail.com"
This would return something like:
[
{
"id": "d992b109-d94a-4d75-9ebb-9ef4e5e851ae",
"LeagueName": "Hipster Kitties",
"UserName": "fake#gmail.com",
"Email": "fake#gmail.com"
}
]

Receiving RequestMalformed error when doing Typesense upsert

I have the following interface in typescript:
export interface TypesenseAtlistedProEvent {
// IDs
id: string;
proId: string;
eventId: string;
startTime: Number;
stopTime: Number;
eventRate: Number;
remainingSlots: Number;
displayName: string;
photoURL: string;
indexOptions: string;
location: Number[];
}
and the following schema in Typesense:
{
"created_at": 1665530883,
"default_sorting_field": "location",
"fields": [
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "proId",
"optional": false,
"sort": false,
"type": "string"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "eventId",
"optional": false,
"sort": false,
"type": "string"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "startTime",
"optional": false,
"sort": true,
"type": "int64"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "stopTime",
"optional": false,
"sort": true,
"type": "int64"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "eventRate",
"optional": false,
"sort": true,
"type": "float"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "remainingSlots",
"optional": false,
"sort": true,
"type": "int32"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "displayName",
"optional": false,
"sort": false,
"type": "string"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "photoURL",
"optional": false,
"sort": false,
"type": "string"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "indexOptions",
"optional": false,
"sort": false,
"type": "string"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "location",
"optional": false,
"sort": true,
"type": "geopoint"
}
],
"name": "atlistedProEventIndex",
"num_documents": 0,
"symbols_to_index": [],
"token_separators": []
}
I look to upsert like the in the following:
const indexedDoc: TypesenseAtlistedProEvent = {
id: proId + eventId,
proId: proId,
eventId: eventId,
startTime: publicEvent.startTime.seconds,
stopTime: publicEvent.stopTime.seconds,
eventRate: publicEvent.eventRate,
remainingSlots: publicEvent.remainingSlots,
displayName: tpi.displayName,
photoURL: tpi.photoURL,
indexOptions: tpi.indexOptions,
location: [tpi.lat, tpi.lng],
};
return await typesenseClient
.collections("atlistedProEventIndex")
.documents()
.upsert(indexedDoc)
.then(() => {
return {success: true, exit: 0};
})
I am getting the following upon the query:
RequestMalformed: Request failed with HTTP code 400 | Server said: [json.exception.type_error.302] type must be number
I am passing it location as Number[], and trying to get that to update the geopoint in typesense. This is not working and thus it would be useful if:
I was able to locate the logs to go through. I would particularly like the logs given by the Typesense Cloud, and am feeling at a loss that I cannot find these.
I would like to pass in the geopoint as the right type in typescript. Right now, as you can see above, the location is of type Number[], which, from the examples I saw, assumed was right. It also may be the case that another field is off and I'm just missing it. Either way, I could really use some kind of server side logging coming from Typesense Cloud.
The error message is a little confusing, but the core of the issue is that the default_sorting_field can only be a numeric field, but it's currently set as a geopoint field (location), which is what that error is trying to convey.
So if you create a new collection without default_sorting_field, the error should not show up.
If you want to sort by geo location, you want to use the sort_by parameter: https://typesense.org/docs/0.23.1/api/geosearch.html#searching-within-a-radius
let searchParameters = {
'q' : '*',
'query_by' : 'title',
'filter_by' : 'location:(48.90615915923891, 2.3435897727061175, 5.1 km)',
'sort_by' : 'location(48.853, 2.344):asc'
}
client.collections('companies').documents().search(searchParameters)

adding analyzers to Azure Search Index using REST API not saving

Having trouble getting the analyzers to save / update on the index. When creating, everything else (the tokenFilters, tokenizers, fields) saves fine, but the analyzers array is always empty?
await client.createOrUpdateIndex(index, { allowIndexDowntime: true });
Creating a new index:
let index = {
name: "test-index",
tokenizers: [{
"odatatype": "#Microsoft.Azure.Search.StandardTokenizerV2",
"name": "test_standard_v2",
"maxTokenLength": 255
}],
fields: [{
"name": "metadata_storage_path",
"type": "Edm.String",
"facetable": false,
"filterable": false,
"key": true,
"retrievable": true,
"searchable": false,
"sortable": false,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
}, {
'name': 'metadata_storage_name',
'type': 'Edm.String',
'facetable': false,
'filterable': false,
'key': false,
'retrievable': true,
'searchable': true,
'sortable': false,
'synonymMaps': [],
'fields': [],
},
{
"name": "partialName",
"type": "Edm.String",
"retrievable": false,
"searchable": true,
"filterable": false,
"sortable": false,
"facetable": false,
"key": false,
"searchAnalyzer": "standardCmAnalyzer",
"indexAnalyzer": "filename_analyzer"
}],
tokenFilters: [{
"name": "nGramCmTokenFilter",
"odatatype": "#Microsoft.Azure.Search.NGramTokenFilterV2",
"minGram": 3,
"maxGram": 20
}],
analyzers: [{
"name": "standardCmAnalyzer",
"odatatype": "#Microsoft.Azure.Search.CustomAnalyzer",
"tokenizer": "test_standard_v2",
"tokenFilters": ["lowercase", "asciifolding"]
},
{
"name": "filename_analyzer",
"odatatype": "#Microsoft.Azure.Search.CustomAnalyzer",
"tokenizer": "test_standard_v2",
"tokenFilters": [
"nGramCmTokenFilter"
]
}],
};
Then creating it:
await client.createOrUpdateIndex(index, { allowIndexDowntime: true });
I noticed no error messages being returned.
EDIT:
Using the sdk #azure/search-documents ^11.1.0

Building mongoose queries programmatically

I'm trying to do a kind of a complex mongoose query. I have searched around and found solutions asking for single variables(with if) and building the query object, but I wanted to know if there is a simpler way because I would be building a query with about 40 non required parameters, for example right now in my req.body I have:
{ searchParams:
{ publicationType: 'Venta',
subtype: [ 'Duplex', 'Cabaña' ],
address:
{
streetNumber: '1312',
streetName: 'José María Bosch',
city: 'Villa Bosch',
state: 'Buenos Aires',
country: 'Argentina' }
}
}
All the names are the same in the database, what I have to do I search if publicationType matches, if the address matches and finally for sub type if any of those array items matches since subtype is a string. Is there any way to do it without an if for each field?
Right now I did this simple query to try out
router.post('/search', (req, res, next) => {
model.Dwelling.find(req.body.searchParams).lean().exec().then(
dwellings => res.send({dwellings})
).catch(next);
});
It works on publicationType and subtype buy not on address.
this is an object in my data base:
{
"_id": {
"$oid": "5af06167ea174f00142bab91"
},
"publicationType": "Alquiler",
"address": {
"latitude": -34.59250669999999,
"altitude": -58.571258599999965,
"streetNumber": "1312",
"streetName": "José María Bosch",
"city": "Villa Bosch",
"state": "Buenos Aires",
"country": "Argentina"
},
"type": "Residencial",
"subtype": "Casa",
"currency": "",
"price": 50000,
"occupationStatus": "Disponible",
"spaces": {
"rooms": 3,
"floors": 0,
"bedrooms": 0,
"closets": 0,
"bathRoom": 0,
"toilette": 0,
"living": false,
"livingDining": false,
"diningRoom": false,
"kitchen": false,
"kitchenDining": false,
"terrace": false,
"balcony": false,
"backYard": false,
"swimmingPool": false,
"barbecue": false,
"garage": "No",
"laundryRoom": "No"
},
"features": {
"status": "Desconocido",
"orientation": "Desconocida",
"luminosity": "Desconocida",
"heating": [
{
"value": "No posee",
"label": "No posee"
}
],
"refurbished": false,
"repair": "No"
},
"services": {
"gas": true,
"water": true,
"sewer": true,
"phone": true,
"pavement": true,
"electricity": true,
"cableTv": true
},
"legal": {
"bank": false,
"prof": false
},
"generalDescription": "Desc 1",
"privateDescription": "Desc 2",
"siocId": 713675,
"createdAt": {
"$date": "2018-05-07T14:23:35.230Z"
},
"updatedAt": {
"$date": "2018-05-07T14:23:35.230Z"
},
"__v": 0
}

Resources