Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996051
user-referenced-in-field.ts
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
user-referenced-in-field.ts
View Options
import
{
Policy
,
Query
,
Context
,
QueryTypes
,
CollectionItem
,
}
from
"../../main.js"
;
export
default
class
UserReferencedInField
extends
Policy
{
static
type_name
=
"user-referenced-in-field"
;
field_name
:
string
;
constructor
(
field_name
:
string
)
{
super
(
field_name
);
this
.
field_name
=
field_name
;
}
async
_getRestrictingQuery
(
context
:
Context
)
{
if
(
!
context
.
user_id
)
return
new
QueryTypes
.
DenyAll
();
return
Query
.
fromSingleMatch
({
[
this
.
field_name
]
:
context
.
user_id
,
});
}
async
checkerFunction
(
context
:
Context
,
item_getter
:
()
=>
Promise
<
CollectionItem
>
)
{
if
(
!
context
.
user_id
)
return
Policy
.
deny
(
context
.
app
.
i18n
(
"policy_logged_in_deny"
));
const
item
=
await
item_getter
();
await
item
.
decode
(
context
);
if
(
context
.
user_id
!==
item
.
get
(
this
.
field_name
))
return
Policy
.
deny
(
context
.
app
.
i18n
(
"policy_user_referenced_in_field_deny"
)
);
return
Policy
.
allow
(
context
.
app
.
i18n
(
"policy_user_referenced_in_field_allow"
,
[
this
.
field_name
,
])
);
}
isItemSensitive
=
async
()
=>
true
;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 08:28 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556797
Default Alt Text
user-referenced-in-field.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment