Class: SyntheticNote

Inherits:
Note show all
Defined in:
app/models/synthetic_note.rb

Direct Known Subclasses

LabelNote, MilestoneNote, StateNote

Constant Summary

Constants inherited from Note

Note::ISSUE_TASK_SYSTEM_NOTE_PATTERN, Note::NON_DIFF_NOTE_TYPES, Note::TYPES_RESTRICTED_BY_GROUP_ABILITY, Note::TYPES_RESTRICTED_BY_PROJECT_ABILITY

Constants included from ThrottledTouch

ThrottledTouch::TOUCH_INTERVAL

Constants included from Gitlab::SQL::Pattern

Gitlab::SQL::Pattern::MIN_CHARS_FOR_PARTIAL_MATCHING, Gitlab::SQL::Pattern::REGEX_QUOTED_TERM

Constants included from ResolvableNote

ResolvableNote::RESOLVABLE_TYPES

Constants included from CacheMarkdownField

CacheMarkdownField::INVALIDATED_BY

Constants included from Redactable

Redactable::UNSUBSCRIBE_PATTERN

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Attribute Summary collapse

Attributes inherited from Note

#command_names, #commands_changes, #redacted_note_html, #skip_keep_around_commits, #total_reference_count, #user_visible_reference_count

Attributes included from CacheMarkdownField

#skip_markdown_cache_validation

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Note

#active?, #attribute_names_for_serialization, #award_emoji?, #banzai_render_context, #broadcast_noteable_notes_changed, #bump_updated_at, #can_be_award_emoji?, #can_be_discussion_note?, #can_create_todo?, #check_for_spam?, cherry_picked_merge_requests, #commit, #confidential?, #contains_emoji_only?, #contributor?, count_for_collection, #diff_note?, #discussion, #discussion_class, #discussion_id, discussions, #editable?, #edited?, #emoji_awardable?, #exportable_record?, find_discussion, #for_alert_mangement_alert?, #for_commit?, #for_design?, #for_issuable?, #for_issue?, #for_merge_request?, #for_personal_snippet?, #for_project_noteable?, #for_project_snippet?, #for_snippet?, #for_vulnerability?, #for_work_item?, grouped_diff_discussions, #hook_attrs, #human_max_access, #in_reply_to?, #issuable_ability_name, #last_edited_at, #max_attachment_size, #mentioned_filtered_user_ids_for, #mentioned_users, #merge_requests, model_name, #noteable, #noteable_ability_name, #noteable_author?, #noteable_type=, #notify_after_create, #notify_after_destroy, #parent_user, #part_of_discussion?, positions, #post_processed_cache_key, #project_name, #references, #retrieve_upload, search, #show_outdated_changes?, simple_sorts, #skip_notification?, #skip_project_check?, #start_of_discussion?, #supports_suggestion?, #system_note_visible_for?, #system_note_with_references?, #to_discussion, #touch, #touch_noteable, #trigger_note_subscription_create, #trigger_note_subscription_destroy, #trigger_note_subscription_update, #user_mention_class, #user_mention_identifier, #user_mentions, with_web_entity_associations

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Spammable

#allow_possible_spam?, #check_for_spam, #check_for_spam?, #clear_spam_flags!, #invalidate_if_spam, #needs_recaptcha!, #recaptcha_error!, #render_recaptcha?, #spam, #spam!, #spam_description, #spam_title, #spammable_attribute_changed?, #spammable_entity_type, #spammable_text, #submittable_as_spam?, #submittable_as_spam_by?, #supports_recaptcha?, #unrecoverable_spam_error!

Methods included from ThrottledTouch

#touch

Methods included from Gitlab::SQL::Pattern

split_query_to_search_terms

Methods included from Editable

#edited?, #last_edited_by

Methods included from ResolvableNote

#potentially_resolvable?, #resolvable?, #resolve!, #resolve_without_save, #resolved?, #to_be_resolved?, #unresolve!, #unresolve_without_save

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods included from CacheMarkdownField

#attribute_invalidated?, #banzai_render_context, #cached_html_for, #cached_html_up_to_date?, #can_cache_field?, #invalidated_markdown_cache?, #latest_cached_markdown_version, #local_version, #mentionable_attributes_changed?, #mentioned_filtered_user_ids_for, #parent_user, #refresh_markdown_cache, #refresh_markdown_cache!, #rendered_field_content, #skip_project_check?, #store_mentions!, #updated_cached_html_for

Methods included from FasterCacheKeys

#cache_key

Methods included from Awardable

#awarded_emoji?, #downvotes, #emoji_awardable?, #grouped_awards, #upvotes, #user_authored?, #user_can_award?

Methods included from Mentionable

#all_references, #create_cross_references!, #create_new_cross_references!, #directly_addressed_users, #extractors, #gfm_reference, #local_reference, #matches_cross_reference_regex?, #mentioned_users, #referenced_group_users, #referenced_groups, #referenced_mentionables, #referenced_project_users, #referenced_projects, #referenced_users, #user_mention_class, #user_mention_identifier

Methods included from Participable

#participant?, #participants, #visible_participants

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Attribute Details

#eventObject

Returns the value of attribute event.



4
5
6
# File 'app/models/synthetic_note.rb', line 4

def event
  @event
end

#resource_parentObject

Returns the value of attribute resource_parent.



4
5
6
# File 'app/models/synthetic_note.rb', line 4

def resource_parent
  @resource_parent
end

Class Method Details

.note_attributes(action, event, resource, resource_parent) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/synthetic_note.rb', line 6

def self.note_attributes(action, event, resource, resource_parent)
  resource ||= event.resource

  attrs = {
    system: true,
    author: event.user,
    created_at: event.created_at,
    updated_at: event.created_at,
    discussion_id: event.discussion_id,
    noteable: resource,
    event: event,
    system_note_metadata: ::SystemNoteMetadata.new(action: action, id: event.discussion_id),
    resource_parent: resource_parent
  }

  if resource_parent.is_a?(Project)
    attrs[:project_id] = resource_parent.id
  end

  attrs
end

Instance Method Details

#groupObject



32
33
34
# File 'app/models/synthetic_note.rb', line 32

def group
  resource_parent if resource_parent.is_a?(Group)
end

#noteObject



36
37
38
# File 'app/models/synthetic_note.rb', line 36

def note
  @note ||= note_text
end

#note_htmlObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'app/models/synthetic_note.rb', line 40

def note_html
  raise NotImplementedError
end

#projectObject



28
29
30
# File 'app/models/synthetic_note.rb', line 28

def project
  resource_parent if resource_parent.is_a?(Project)
end